I have 2 web form pages.
Page 1 collects user information using text boxes.
Page 2 displays the users information entered in page 1.
I have a text box on page 1, this collects the users first name and stores in a class property
MyClass.Firstname = txtFirstName.Text
On page 2 I use a literal control to display the first name
litName.Text = MyClass.Firstname;
This all is fine but then I test it adding some scripts to the textbox and go to page 2. When I go to page 2 it executes the script but I want it to show it as text and not run the script
I tried
litName.Text = Server.HtmlEncode(MyClass.Firstname);
But this still executes the script. How can i just display this as text?
Also if I do encode/decode the text and the user goes back to page 1 if they entered a script tag on page 1 and they go back the text shows as
<script>
how could I display this back to the correct format. Appreciate if anyone could give me an example to follow.