Showing posts with label dropdowns. Show all posts
Showing posts with label dropdowns. Show all posts

Friday, March 16, 2012

Password Field

Have a textbox that's in Password mode on a user creation page. Have
several dropdowns that cause a PostBack out of necessity on this page. I
cannot separate them. When one of these dropdowns changes, the textbox's
value is lost. How do I prevent this?

Thanksthe best way would be to remember it from the original postback, so it only
passes over the network once. otherwise you can use a hack, and set the
control's "value" attribute.

-- bruce (sqlwork.com)

"James" <minorkeys@.gmail.com> wrote in message
news:ODtJUcjEGHA.516@.TK2MSFTNGP15.phx.gbl...
> Have a textbox that's in Password mode on a user creation page. Have
> several dropdowns that cause a PostBack out of necessity on this page. I
> cannot separate them. When one of these dropdowns changes, the textbox's
> value is lost. How do I prevent this?
> Thanks
Can I? I've tried setting it in my Page Load event and it doesn't seem to
persist. I've also tried using a client side control with runat=server.
None of the above seem to want to let me set the value.

"Bruce Barker" <brubar_nospamplease_@.safeco.com> wrote in message
news:umI$3ijEGHA.2012@.TK2MSFTNGP14.phx.gbl...
> the best way would be to remember it from the original postback, so it
> only passes over the network once. otherwise you can use a hack, and set
> the control's "value" attribute.
> -- bruce (sqlwork.com)
>
> "James" <minorkeys@.gmail.com> wrote in message
> news:ODtJUcjEGHA.516@.TK2MSFTNGP15.phx.gbl...
>> Have a textbox that's in Password mode on a user creation page. Have
>> several dropdowns that cause a PostBack out of necessity on this page. I
>> cannot separate them. When one of these dropdowns changes, the textbox's
>> value is lost. How do I prevent this?
>>
>> Thanks
>>
You have to do it on the client side using javascript.

Losing the value of a password field is pretty standard. If the password
field is the last one on your page, it should in theory be the last field a
user fills in, so it geting emptied shouldn't really happen.

"James" <minorkeys@.gmail.com> wrote in message
news:%235n36mjEGHA.3200@.tk2msftngp13.phx.gbl...
> Can I? I've tried setting it in my Page Load event and it doesn't seem to
> persist. I've also tried using a client side control with runat=server.
> None of the above seem to want to let me set the value.
> "Bruce Barker" <brubar_nospamplease_@.safeco.com> wrote in message
> news:umI$3ijEGHA.2012@.TK2MSFTNGP14.phx.gbl...
>> the best way would be to remember it from the original postback, so it
>> only passes over the network once. otherwise you can use a hack, and set
>> the control's "value" attribute.
>>
>> -- bruce (sqlwork.com)
>>
>>
>>
>> "James" <minorkeys@.gmail.com> wrote in message
>> news:ODtJUcjEGHA.516@.TK2MSFTNGP15.phx.gbl...
>>> Have a textbox that's in Password mode on a user creation page. Have
>>> several dropdowns that cause a PostBack out of necessity on this page.
>>> I cannot separate them. When one of these dropdowns changes, the
>>> textbox's value is lost. How do I prevent this?
>>>
>>> Thanks
>>>
>>
>>
JavaScript doesn't seem to work either. It isn't the last field they will
enter, and even if it were, there's no way they'd go for that =/.

"Marina" <someone@.nospam.com> wrote in message
news:OTk4sojEGHA.524@.TK2MSFTNGP09.phx.gbl...
> You have to do it on the client side using javascript.
> Losing the value of a password field is pretty standard. If the password
> field is the last one on your page, it should in theory be the last field
> a user fills in, so it geting emptied shouldn't really happen.
> "James" <minorkeys@.gmail.com> wrote in message
> news:%235n36mjEGHA.3200@.tk2msftngp13.phx.gbl...
>> Can I? I've tried setting it in my Page Load event and it doesn't seem
>> to persist. I've also tried using a client side control with
>> runat=server. None of the above seem to want to let me set the value.
>>
>> "Bruce Barker" <brubar_nospamplease_@.safeco.com> wrote in message
>> news:umI$3ijEGHA.2012@.TK2MSFTNGP14.phx.gbl...
>>> the best way would be to remember it from the original postback, so it
>>> only passes over the network once. otherwise you can use a hack, and set
>>> the control's "value" attribute.
>>>
>>> -- bruce (sqlwork.com)
>>>
>>>
>>>
>>> "James" <minorkeys@.gmail.com> wrote in message
>>> news:ODtJUcjEGHA.516@.TK2MSFTNGP15.phx.gbl...
>>>> Have a textbox that's in Password mode on a user creation page. Have
>>>> several dropdowns that cause a PostBack out of necessity on this page.
>>>> I cannot separate them. When one of these dropdowns changes, the
>>>> textbox's value is lost. How do I prevent this?
>>>>
>>>> Thanks
>>>>
>>>
>>>
>>
>>
I know for a fact that if you set the value on an input control that is a
password type in javascript, that it does get set correctly. Maybe you need
to post your code then.

I bet your users will like the fact that their password is being sent in
clear text in the browser even less then having to retype their password,
since that is the only way to preserve it in between posts. I would
recommend either accepting that passwords will be blank between posts (this
happens pretty much in every other registration system), re-organize your
registration in such a way that the password gets its own page and it is the
last page in the registration process, or code using the javascript solution
and have the password be sent in clear text - which should be the last
resort.

"James" <minorkeys@.gmail.com> wrote in message
news:uzLRXrjEGHA.1032@.TK2MSFTNGP11.phx.gbl...
> JavaScript doesn't seem to work either. It isn't the last field they will
> enter, and even if it were, there's no way they'd go for that =/.
> "Marina" <someone@.nospam.com> wrote in message
> news:OTk4sojEGHA.524@.TK2MSFTNGP09.phx.gbl...
>> You have to do it on the client side using javascript.
>>
>> Losing the value of a password field is pretty standard. If the password
>> field is the last one on your page, it should in theory be the last field
>> a user fills in, so it geting emptied shouldn't really happen.
>>
>> "James" <minorkeys@.gmail.com> wrote in message
>> news:%235n36mjEGHA.3200@.tk2msftngp13.phx.gbl...
>>> Can I? I've tried setting it in my Page Load event and it doesn't seem
>>> to persist. I've also tried using a client side control with
>>> runat=server. None of the above seem to want to let me set the value.
>>>
>>> "Bruce Barker" <brubar_nospamplease_@.safeco.com> wrote in message
>>> news:umI$3ijEGHA.2012@.TK2MSFTNGP14.phx.gbl...
>>>> the best way would be to remember it from the original postback, so it
>>>> only passes over the network once. otherwise you can use a hack, and
>>>> set the control's "value" attribute.
>>>>
>>>> -- bruce (sqlwork.com)
>>>>
>>>>
>>>>
>>>> "James" <minorkeys@.gmail.com> wrote in message
>>>> news:ODtJUcjEGHA.516@.TK2MSFTNGP15.phx.gbl...
>>>>> Have a textbox that's in Password mode on a user creation page. Have
>>>>> several dropdowns that cause a PostBack out of necessity on this page.
>>>>> I cannot separate them. When one of these dropdowns changes, the
>>>>> textbox's value is lost. How do I prevent this?
>>>>>
>>>>> Thanks
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
Thanks for the help, this seems to work on Postback:

tbPassword.Attributes("value") = tbPassword.Text

"Marina" <someone@.nospam.com> wrote in message
news:eKbInxjEGHA.216@.TK2MSFTNGP15.phx.gbl...
>I know for a fact that if you set the value on an input control that is a
>password type in javascript, that it does get set correctly. Maybe you
>need to post your code then.
> I bet your users will like the fact that their password is being sent in
> clear text in the browser even less then having to retype their password,
> since that is the only way to preserve it in between posts. I would
> recommend either accepting that passwords will be blank between posts
> (this happens pretty much in every other registration system), re-organize
> your registration in such a way that the password gets its own page and it
> is the last page in the registration process, or code using the javascript
> solution and have the password be sent in clear text - which should be the
> last resort.
> "James" <minorkeys@.gmail.com> wrote in message
> news:uzLRXrjEGHA.1032@.TK2MSFTNGP11.phx.gbl...
>> JavaScript doesn't seem to work either. It isn't the last field they
>> will enter, and even if it were, there's no way they'd go for that =/.
>>
>> "Marina" <someone@.nospam.com> wrote in message
>> news:OTk4sojEGHA.524@.TK2MSFTNGP09.phx.gbl...
>>> You have to do it on the client side using javascript.
>>>
>>> Losing the value of a password field is pretty standard. If the
>>> password field is the last one on your page, it should in theory be the
>>> last field a user fills in, so it geting emptied shouldn't really
>>> happen.
>>>
>>> "James" <minorkeys@.gmail.com> wrote in message
>>> news:%235n36mjEGHA.3200@.tk2msftngp13.phx.gbl...
>>>> Can I? I've tried setting it in my Page Load event and it doesn't seem
>>>> to persist. I've also tried using a client side control with
>>>> runat=server. None of the above seem to want to let me set the value.
>>>>
>>>> "Bruce Barker" <brubar_nospamplease_@.safeco.com> wrote in message
>>>> news:umI$3ijEGHA.2012@.TK2MSFTNGP14.phx.gbl...
>>>>> the best way would be to remember it from the original postback, so it
>>>>> only passes over the network once. otherwise you can use a hack, and
>>>>> set the control's "value" attribute.
>>>>>
>>>>> -- bruce (sqlwork.com)
>>>>>
>>>>>
>>>>>
>>>>> "James" <minorkeys@.gmail.com> wrote in message
>>>>> news:ODtJUcjEGHA.516@.TK2MSFTNGP15.phx.gbl...
>>>>>> Have a textbox that's in Password mode on a user creation page. Have
>>>>>> several dropdowns that cause a PostBack out of necessity on this
>>>>>> page. I cannot separate them. When one of these dropdowns changes,
>>>>>> the textbox's value is lost. How do I prevent this?
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>

Password Field

Have a textbox that's in Password mode on a user creation page. Have
several dropdowns that cause a PostBack out of necessity on this page. I
cannot separate them. When one of these dropdowns changes, the textbox's
value is lost. How do I prevent this?
Thanksthe best way would be to remember it from the original postback, so it only
passes over the network once. otherwise you can use a hack, and set the
control's "value" attribute.
-- bruce (sqlwork.com)
"James" <minorkeys@.gmail.com> wrote in message
news:ODtJUcjEGHA.516@.TK2MSFTNGP15.phx.gbl...
> Have a textbox that's in Password mode on a user creation page. Have
> several dropdowns that cause a PostBack out of necessity on this page. I
> cannot separate them. When one of these dropdowns changes, the textbox's
> value is lost. How do I prevent this?
> Thanks
>
Can I? I've tried setting it in my Page Load event and it doesn't seem to
persist. I've also tried using a client side control with runat=server.
None of the above seem to want to let me set the value.
"Bruce Barker" <brubar_nospamplease_@.safeco.com> wrote in message
news:umI$3ijEGHA.2012@.TK2MSFTNGP14.phx.gbl...
> the best way would be to remember it from the original postback, so it
> only passes over the network once. otherwise you can use a hack, and set
> the control's "value" attribute.
> -- bruce (sqlwork.com)
>
> "James" <minorkeys@.gmail.com> wrote in message
> news:ODtJUcjEGHA.516@.TK2MSFTNGP15.phx.gbl...
>
You have to do it on the client side using javascript.
Losing the value of a password field is pretty standard. If the password
field is the last one on your page, it should in theory be the last field a
user fills in, so it geting emptied shouldn't really happen.
"James" <minorkeys@.gmail.com> wrote in message
news:%235n36mjEGHA.3200@.tk2msftngp13.phx.gbl...
> Can I? I've tried setting it in my Page Load event and it doesn't seem to
> persist. I've also tried using a client side control with runat=server.
> None of the above seem to want to let me set the value.
> "Bruce Barker" <brubar_nospamplease_@.safeco.com> wrote in message
> news:umI$3ijEGHA.2012@.TK2MSFTNGP14.phx.gbl...
>
JavaScript doesn't seem to work either. It isn't the last field they will
enter, and even if it were, there's no way they'd go for that =/.
"Marina" <someone@.nospam.com> wrote in message
news:OTk4sojEGHA.524@.TK2MSFTNGP09.phx.gbl...
> You have to do it on the client side using javascript.
> Losing the value of a password field is pretty standard. If the password
> field is the last one on your page, it should in theory be the last field
> a user fills in, so it geting emptied shouldn't really happen.
> "James" <minorkeys@.gmail.com> wrote in message
> news:%235n36mjEGHA.3200@.tk2msftngp13.phx.gbl...
>
I know for a fact that if you set the value on an input control that is a
password type in javascript, that it does get set correctly. Maybe you need
to post your code then.
I bet your users will like the fact that their password is being sent in
clear text in the browser even less then having to retype their password,
since that is the only way to preserve it in between posts. I would
recommend either accepting that passwords will be blank between posts (this
happens pretty much in every other registration system), re-organize your
registration in such a way that the password gets its own page and it is the
last page in the registration process, or code using the javascript solution
and have the password be sent in clear text - which should be the last
resort.
"James" <minorkeys@.gmail.com> wrote in message
news:uzLRXrjEGHA.1032@.TK2MSFTNGP11.phx.gbl...
> JavaScript doesn't seem to work either. It isn't the last field they will
> enter, and even if it were, there's no way they'd go for that =/.
> "Marina" <someone@.nospam.com> wrote in message
> news:OTk4sojEGHA.524@.TK2MSFTNGP09.phx.gbl...
>
Thanks for the help, this seems to work on Postback:
tbPassword.Attributes("value") = tbPassword.Text
"Marina" <someone@.nospam.com> wrote in message
news:eKbInxjEGHA.216@.TK2MSFTNGP15.phx.gbl...
>I know for a fact that if you set the value on an input control that is a
>password type in javascript, that it does get set correctly. Maybe you
>need to post your code then.
> I bet your users will like the fact that their password is being sent in
> clear text in the browser even less then having to retype their password,
> since that is the only way to preserve it in between posts. I would
> recommend either accepting that passwords will be blank between posts
> (this happens pretty much in every other registration system), re-organize
> your registration in such a way that the password gets its own page and it
> is the last page in the registration process, or code using the javascript
> solution and have the password be sent in clear text - which should be the
> last resort.
> "James" <minorkeys@.gmail.com> wrote in message
> news:uzLRXrjEGHA.1032@.TK2MSFTNGP11.phx.gbl...
>

Password field is cleared after postback

Hello,
I am developing a C# asp.net application.
I have a webform which contains 2 dropdowns and a textbox with
type="password".
On "SelectedIndexChanged" event of the first dropdown, there is a postback,
in order to fill the second dropdown according to the value selected in the
first dropdown.
The problem is that the password field which has been filled up before is
cleared after postback.
I know this is for security, but is there a way to keep the password'
Thank youdana lees wrote:

> Hello,
> I am developing a C# asp.net application.
> I have a webform which contains 2 dropdowns and a textbox with
> type="password".
> On "SelectedIndexChanged" event of the first dropdown, there is a
> postback, in order to fill the second dropdown according to the value
> selected in the first dropdown.
> The problem is that the password field which has been filled up before is
> cleared after postback.
> I know this is for security, but is there a way to keep the password'
> Thank you
Yes, you can add a "value" attribute to the password textbox on postback:
txtPassword.Attributes.Add("value", txtPassword.Text)
Ben
I have tried that and it didn't work. The field stayed empty...
"Ben Amada" <ben@.REpoMOweVErpick.com> wrote in message
news:OaFdNkA8FHA.3804@.TK2MSFTNGP12.phx.gbl...
> dana lees wrote:
>
is
> Yes, you can add a "value" attribute to the password textbox on postback:
> txtPassword.Attributes.Add("value", txtPassword.Text)
> Ben
>
dana lees wrote:

> I have tried that and it didn't work. The field stayed empty...
Hmm... not sure why that doesn't work. Are you using .NET v2.0? I've done
it in v1.1 without any problems.
Another option is to manually set the value of the password field via
JavaScript. There are several ways to do this.
One way is to create a hidden input field. On postback, put the password in
the hidden input field (i.e. txtHiddenPwd.Value = txtPwd.Text). Then with a
startup script or via the body tag's onload attribute, set the value of the
password textbox to the value of the hidden input field.
Ben
I am using version 1.1.
On debug, I see that i do have the value of the password after postback, i
just can't set the textbox with that value.
I have tried also java script:
document.all.txtPassword.InnerText = "some text";
and this doesn't work as well...
I don't need to use a hidden textbox becuase i do have the value after
postback, i just can't set the textbox's value to that value...
"Ben Amada" <ben@.REpoMOweVErpick.com> wrote in message
news:u2Kz1wA8FHA.4076@.tk2msftngp13.phx.gbl...
> dana lees wrote:
>
> Hmm... not sure why that doesn't work. Are you using .NET v2.0? I've
done
> it in v1.1 without any problems.
> Another option is to manually set the value of the password field via
> JavaScript. There are several ways to do this.
> One way is to create a hidden input field. On postback, put the password
in
> the hidden input field (i.e. txtHiddenPwd.Value = txtPwd.Text). Then with
a
> startup script or via the body tag's onload attribute, set the value of
the
> password textbox to the value of the hidden input field.
> Ben
>
dana lees wrote:

> I am using version 1.1.
> On debug, I see that i do have the value of the password after postback, i
> just can't set the textbox with that value.
> I have tried also java script:
> document.all.txtPassword.InnerText = "some text";
> and this doesn't work as well...
> I don't need to use a hidden textbox becuase i do have the value after
> postback, i just can't set the textbox's value to that value...
Server-side you can't set the textbox's value to the password. However,
with JavaScript (client-side) you should be able to set the value of the
textbox with or without a hidden input field. Without a hidden input field,
you could simply add a runat="server" attribute to the <body> tag, then on
the server-side during a postback, you can add an "onload" attribute to the
body tag specifying the password value. Like this:
===== HTML =====
<body id="myBody" runat="server">
===== Code-Behind =====
myBody.Attributes.Add("onload", _
"document.getElementById('txtPassword').value = '" & _
txtPassword.Text & "'")
(the C# syntax should be similar)
Also, in the code-behind, if Visual Studio doesn't recognize the "myBody"
control (which happens sometimes), you'll probably have to manually add the
control declaration to the code-behind:
Dim myBody As HtmlControls.HtmlGenericControl
... or instead of adding an "onload" attribute to the body tag, you could
use the RegisterStartupScript method to set the password textbox value.
Ben
dana lees wrote:

> I have tried also java script:
> document.all.txtPassword.InnerText = "some text";
> and this doesn't work as well...
By the way, what do you mean that it "doesn't work as well"? How about :
document.getElementById('txtPassword').value = "some text";
Ben
It worked, when using
document.getElementById('txtPassword').value = "some text";
Thank you very much :-)
"Ben Amada" <ben@.REpoMOweVErpick.com> wrote in message
news:%23G3ExQB8FHA.3200@.TK2MSFTNGP11.phx.gbl...
> dana lees wrote:
>
> By the way, what do you mean that it "doesn't work as well"? How about :
> document.getElementById('txtPassword').value = "some text";
> Ben
>
Dana,
As Ben suggested you can use assword.Attributes.Add("value",
txtPassword.Text) to set the password .But instead of txtPassword.Text you
should retrieve password text using
txtPassword.Attributes["value"].ToString().
"dana lees" wrote:

> I have tried that and it didn't work. The field stayed empty...
> "Ben Amada" <ben@.REpoMOweVErpick.com> wrote in message
> news:OaFdNkA8FHA.3804@.TK2MSFTNGP12.phx.gbl...
> is
>
>
Check out:
http://groups.google.com/group/micr...de23fa30643fa4e
and
http://groups.google.com/group/micr...f9f3be06c4f0396
(watch for link brakage). Basically, you need to reset the value manually
via Password.Attributes.Add("value", Password.Text) or something
karl
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
"dana lees" <danal@.idc.ac.il> wrote in message
news:%23jWQj9$7FHA.4036@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I am developing a C# asp.net application.
> I have a webform which contains 2 dropdowns and a textbox with
> type="password".
> On "SelectedIndexChanged" event of the first dropdown, there is a
> postback,
> in order to fill the second dropdown according to the value selected in
> the
> first dropdown.
> The problem is that the password field which has been filled up before is
> cleared after postback.
> I know this is for security, but is there a way to keep the password'
> Thank you
>