?
Solved

Losing data in a password textbox on postback

Posted on 2010-09-22
5
Medium Priority
?
2,180 Views
Last Modified: 2012-05-10
I have a password textbox in my page.Also there is drwopdownlist in same form.my problem is when i changing an item in the drowdownlist,password textbox also get cleared.How can i solve this.The entire thing is inside a tab page.  
<ajaxToolkit:TabPanel ID="tpUserMgmt" runat="server" HeaderText="User Management">
<asp:UpdatePanel ID="Panel_UserProf" runat="server">
  <ContentTemplate>
 <asp:TextBox ID="txt_Pwd" runat="server" MaxLength="15" TextMode="Password"  ValidationGroup="CreateUser" Width="130px">
<asp:DropDownList ID="dd_Dsgnt" runat="server" Width="130px" OnSelectedIndexChanged="dd_Dsgnt_SelectedIndexChanged"
                                                        AutoPostBack="true">
                                                    </asp:DropDownList>
   </ContentTemplate>
   </asp:UpdatePanel>
</ajaxToolkit:TabPanel>
0
Comment
Question by:vivekpv10
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 14

Accepted Solution

by:
existenz2 earned 1000 total points
ID: 33741481
0
 
LVL 14

Expert Comment

by:robasta
ID: 33741710
1.AutoPostBack="true" on a Dropdownlist will do a postback
2. TextMode="Password" on a Textbox will clear contents after a postback

There are different ways to solve this 'by design' scenario. The following are suggestions:

a) Save the password in session or in a hidden field and put it back after the postback(not sure about the security risks involved here).
b) Add the textbox below the dropdown, so that the user enters password after drop down has already done a postback
c) Take the textbox outside the updatepanel
d) place the password box on a seperate tab...
0
 
LVL 5

Author Comment

by:vivekpv10
ID: 33742034
anyone know how it can be implemented using javascript??pls post that code also
0
 
LVL 3

Assisted Solution

by:revaluser
revaluser earned 1000 total points
ID: 33742225
which ever the action is causing the postback action place this code

string strPasswordValue = TextBox1.Text.Trim();
TextBox1.Attributes.Add("Value", strPasswordValue);

Over there

like

protected void Button1_Click(object sender, EventArgs e)
    {
        string strPasswordValue = TextBox1.Text.Trim();
        TextBox1.Attributes.Add("Value", strPasswordValue);
    }
0
 
LVL 5

Author Closing Comment

by:vivekpv10
ID: 33742353
awesome ansers..its working
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The most up-to-date version of this article is on my Blog https://iconoun.com/blog/
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question