Solved

Losing data in a password textbox on postback

Posted on 2010-09-22
5
2,018 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
5 Comments
 
LVL 14

Accepted Solution

by:
existenz2 earned 250 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 250 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

831 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