Help needed in ASP.Net 2.0 Text Box Password Mode

  • Thread starter Thread starter SenthilVel
  • Start date Start date
S

SenthilVel

hi all,
i am running a ASP.Net 2.0 application.
in one of the pages i have a text box which is set as PASSWORD mode.
when the page is submitted or transfered , am not able to get the contents
of this textbox which is in Password mode.

do we need to any more apart from setting to password mode to get the value
present in the text box..?

do we need to do anything in specific with the viewstates if there is
security with ASP.Net Password text boxes?

Please let me know

Thanks
Senthil
 
A password box acts as normal, are you referring to the fact that the box
isn't pre-populated after a postback? If so then add a VALUE attribute to
it with the value of txtYourPasswordBox.Text
 
Is your password textbox created programatically?
Check this.

As Aidy said, this can be about PostBack problems. For example in your
Page_Load code

protected void Page_Load(object sender, EventArgs e)
{
// .. some other c# codes
txtPassword.Text = "";
// .. some other c# codes
}
When postback the current value will be lost, so you have to control it like
protected void Page_Load(object sender, EventArgs e)
{
// .. some other c# codes
if(!Page.IsPostBack)
txtPassword.Text = "";
// .. some other c# codes
}
 
hi
thanks for the info ...
question:
to get the value of the password textbox , do we set the value in the
Viewstate ? and then assign to the Value Attribute ?

Please let me know step by step ..

,,,
Senthil
 
in one of the blogs i saw a solution like :

setting txtbox.attributes("value") = txtbox.text
this was added in the preresender event of the text box...

Question: Is this a limitation with the textbox that we need to this step
maunally ?
is this a security feature ?

,,,
Senthil
 
Hi,

No we don't need to set viewstate.
If you have a textbox like this

<asp:TextBox id="txtPass" runat="server" TextMode="Password" />

you can get its value by
txtPass.Text property.

You don't need to anything more..
 
hi,

i did the same way as u were saying ..just have the <asp:TextBox
id="txtPass" runat="server" TextMode="Password" />

But once a post back is happeining or when the value in the text boz is
accessed in a button click event , still the password is null !!

am not able to get the password value !!
do we need to do something like this ?

ViewState["Pwd"]=TextBox1.Text
TextBox1.Attributes.Add("value", ViewState["Pwd"].ToString ()) ;

,,,
Senthil
 
Back
Top