Solved

Losing data in a password textbox on postback

Posted on 2010-09-22
5
2,102 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 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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

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
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

705 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