I have a dropdownlist on my web page along with a textbox which has property set to password field.

Now dropdownlist has autopostback property true.

When i change anything in dropdownlist, Password field gets erased.

So how can i prevent password field from getting empty at time of page post back

Recommended Answers

All 4 Replies

Easiest answer, disable autopostback on the dropdown.

the password form is getting posted back to the server every time there is a postback, you'll need to grab it at the same time you take care of the dropdown box, otherwise you need to change when your postbacks are occurring.

I got Answer

protected override void OnPreRender(EventArgs e)
    {
        txtPassword.Attributes.Add("value", txtPassword.Text);
        base.OnPreRender(e);
    }

Hello Makarand,

I think that will expose your password on the client side. Must be session variables would be a good thought.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.