<asp:TextBox ID="TextBox1" runat="server" value='<%=Server.HtmlEncode
(Request.Cookies("Username")("Username"))%>'/>
<input name="Password" type="text" id="Password" value='<%
=Server.HtmlEncode(Request.Cookies("Username")("Us ername"))%>'>
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("Username")
Dim dt As DateTime = DateTime.Now()
Dim ts As New TimeSpan(1,0,10,0)
MyCookie.Expires = dt.Add(ts)
MyCookie.Domain = "jmac-solutions.com"
MyCookie.Path = "/photoshare"
MyCookie.Values("Username") = "jm*****@jmac-solutions.com"
Response.Cookies.Add(MyCookie)
End If
End Sub
</script>
code for retrieving cookie info
_________________________________
<script runat="server">
Sub Page_Load()
Dim bc As HttpBrowserCapabilities
Dim CookiesAvailable
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").Value
Response.Write(str & " <br>")
If Not Request.Cookies("Username") Is Nothing Then
Label1.Text = Server.HtmlEncode(Request.Cookies("Username")("Use rname"))
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='<%=Server.HtmlEncode
(Request.Cookies("Username")("Username"))%>'/>
<input name="Password" type="text" id="Password" value='<%
=Server.HtmlEncode(Request.Cookies("Username")("Us ername"))%>'>
</form>
--
Message posted via http://www.dotnetmonster.com