Help needed in ASP.Net 2.0 Text Box Password Mode

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

Aidy

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
 
?

=?iso-8859-9?Q?Bahad=FDr_ARSLAN?=

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
}
 
S

SenthilVel

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
 
S

SenthilVel

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
 
?

=?iso-8859-9?Q?Bahad=FDr_ARSLAN?=

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..
 
S

SenthilVel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top