I default.aspx form tag content
& lt; ASP: Button ID = "Button save" runat = "server" text = "save" height = "47px" width = "176px" /> & Lt; ASP: Text Box ID = "Text Box Cookie" Run = "Server" & gt; & Lt; / Asp: text box & gt;
What I want to do text box string I saved through the bottom after closing the full written text box on the page and open it again. Behind my text
Protected Sub Page_Load (ByVal as the object, as ByVal e EventArgs) TextBoxCookie.Text = Request.Cookies ( "TextCookie"). Value End Sub Protected Sub ButtonSave_Click (as object, e EventArgs) as handle ButtonSave.Click dim aCookie New HttpCookie ( "TextCookie") aCookie.Value = TextBoxCookie.Text.ToString aCookie.Expires = DateTime.Now.AddDays (1) Response.Cookies.Add (aCookie) end as sub
But after the page is closed the text box is empty Can anyone tell me what code because I do not do it Is wrong with getting it
-
If you want to set only
TextBoxCookie
value If the page is not a post back. Otherwise, the flow of your page is for typing a price for you, click on the button, then back to the post you are writing the value that you have written with the value of the cookie (which is probably empty). Then,ButtonSave_Click
is implemented and the cookie set of value for the text box (which is now empty and not which you typed). -
Keep in mind that the
button looks like followed by
Page_Load
. Please review.
So, only set the value of the text, when no posts are back
protected by Sub Page_Load (ByVal sender as the object as EventArgs ByVal and) if not Page.IsPostBackTextBoxCookie.Text = Request.Cookies ( "TextCookie"). Price end if the end subs >>
No comments:
Post a Comment