Hi,
I tried the below code and it does not show the password in the
textbox. Any thoughts?
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim cUsername, cPassword As String
If Not Page.IsPostBack Then
If Not Request.Cookies("cUsername") Is Nothing Then
cUsername = Request.Cookies("cUsername").Value
TextBox1.Text = cUsername
End If
If Not Request.Cookies("cPassword") Is Nothing Then
cPassword = Request.Cookies("cPassword").Value
ViewState("OrigPassword") = cPassword
TextBox2.Text = ViewState("OrigPassword")
End If
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim cUsername, cPassword As String
If Request.Cookies("cUsername") Is Nothing Then
Dim cNewUsernameCookie As New HttpCookie("cUsername",
TextBox1.Text)
cNewUsernameCookie.Expires = DateTime.Now.AddDays(5)
Response.Cookies.Add(cNewUsernameCookie)
Else
Response.Cookies("cUsername").Value = TextBox1.Text
Response.Cookies("cUsername").Expires =
DateTime.Now.AddDays(5)
End If
If Request.Cookies("cUsername") Is Nothing Then
Dim cNewPasswordCookie As New HttpCookie("cPassword",
TextBox2.Text)
cNewPasswordCookie.Expires = DateTime.Now.AddDays(5)
Response.Cookies.Add(cNewPasswordCookie)
Else
Response.Cookies("cPassword").Value = TextBox2.Text
Response.Cookies("cPassword").Expires =
DateTime.Now.AddDays(5)
End If
End Sub
*********************************************************************
--- In [email protected], Dean Fiala
<[EMAIL PROTECTED]> wrote:
> This is a security feature of ASP.NET, it won't let you put a
password
> in your page source (which what you would be doing).
>
> Couple ways around it. Store the actual password in viewstate or a
> session variable , then in your server code check to see if the user
> has entered a password, if not, use the stored values. Imagine you
> are doing this to allow account add/update on the same page. If so
> will need to turn off the required field validator for the password
> field when updating.
>
> There was some discussion of this in this group late last year or
> earlier this year, with some more creative work-arounds if this does
> not satisfy your needs.
>
> On 7/28/05, esimplest <[EMAIL PROTECTED]> wrote:
> > When i am assigning cookie field to a password text box on the
form, it
> > does not show anything - but it does when i make the text box
single
> > line?
> >
> > Any thoughts.
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> Dean Fiala
> Very Practical Software, Inc
> http://www.vpsw.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a
href="http://us.ard.yahoo.com/SIG=12hqelci0/M=362329.6886308.7839368.1510227/D=groups/S=1705006764:TM/Y=YAHOO/EXP=1122879047/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992
">Fair play? Video games influencing politics. Click and talk back!</a>.</font>
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/