<asp:TextBox ID="TextBox1" runat="server" value='<%=Serve r.HtmlEncode
(Request.Cookie s("Username")(" Username"))%>'/>
<input name="Password" type="text" id="Password" value='<%
=Server.HtmlEnc ode(Request.Coo kies("Username" )("Username"))% >'>
i have created a cookie and want to use it with my login page. I currently
have asp:TextBox with form validation control. I can get the cookie value
to appear but not in the asp:TextBox. I can use a label to show it on the
page or in a standard HTML text field. I don't understand what is going
on. Can we not bind values to the asp:TextBox?
code for setting cookie works
_______________ ______________
<script runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
If NOT IsPostBack Then
Dim MyCookie As HttpCookie = New HttpCookie("Use rname")
Dim dt As DateTime = DateTime.Now()
Dim ts As New TimeSpan(1,0,10 ,0)
MyCookie.Expire s = dt.Add(ts)
MyCookie.Domain = "jmac-solutions.com"
MyCookie.Path = "/photoshare"
MyCookie.Values ("Username") = "jm*****@jm ac-solutions.com"
Response.Cookie s.Add(MyCookie)
End If
End Sub
</script>
code for retrieving cookie info
_______________ _______________ ___
<script runat="server">
Sub Page_Load()
Dim bc As HttpBrowserCapa bilities
Dim CookiesAvailabl e
bc = Request.Browser
If bc.Cookies Then
Message.Text = "Cookies are available with this browser.<br>"
Message.Text &= "Save login info?: <input type=checkbox name=checkbox
value=checkbox> "
Else
Message.Text = "Cookies are NOT available with this browser"
End If
Dim str As String
str = Request.Cookies ("Username").Va lue
Response.Write( str & " <br>")
If Not Request.Cookies ("Username") Is Nothing Then
Label1.Text = Server.HtmlEnco de(Request.Cook ies("Username") ("Username") )
End If
End Sub
</script>
<form runat="server">
<asp:Label id="Message" runat="server" /><br>
<asp:Label id="Label1" runat="server" /> <br>
<asp:TextBox ID="TextBox1" runat="server" value='<%=Serve r.HtmlEncode
(Request.Cookie s("Username")(" Username"))%>'/>
<input name="Password" type="text" id="Password" value='<%
=Server.HtmlEnc ode(Request.Coo kies("Username" )("Username"))% >'>
</form>
--
Message posted via http://www.dotnetmonster.com