Password field is getting cleared !!

Posted by .Netlearner under ASP.NET on 7/26/2012 | Points: 10 | Views : 1238 | Status : [Member] | Replies : 3
Hello All ,
In my signup page Am having a dropdownlist and selectedindexchanged event in that when i select some value from the dropdown list ,password and confirm passford fields intext box entered before choosing the dropdownlist is getting cleared !

What should i do to avoid this.

<tr>
<td align="left">
<asp:Label ID="lblpwd" runat="server" Text="Password"></asp:Label>

</td>
<td align="left">
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" MaxLength="15" Width="150px"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ControlToValidate="txtPassword"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="left">
<asp:Label ID="lblcpwd" runat="server" Text="Confirm Password"></asp:Label>

</td>
<td align="left">
<asp:TextBox ID="txtCPwd" runat="server" TextMode="password" MaxLength="15" Width="150px"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*" ControlToValidate="txtCPwd"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="left">
<asp:Label ID="lblPwdQues" runat="server" Text="Security Password<BR> Question"></asp:Label>

</td>
<td align="left">
<asp:DropDownList ID="ddlpwdques" runat="server" Width="150px" OnSelectedIndexChanged="ddlpwdques_OnSelectedIndexChanged" AutoPostBack="true">
<asp:ListItem>Select One</asp:ListItem>
<asp:ListItem>Memorable Day?</asp:ListItem>
<asp:ListItem>Pet's Name?</asp:ListItem>
<asp:ListItem>First School?</asp:ListItem>
<asp:ListItem>Favourite Place?</asp:ListItem>
<asp:ListItem>Favourite Color?</asp:ListItem>
</asp:DropDownList>
</td>
</tr>





Responses

Posted by: Vuyiswamb on: 7/26/2012 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Your Problem is the post back that makes your page to refresh. What you need to do is to wrap your Control in an UpdatePanel as depicted in my video here

http://www.dotnetfunda.com/tutorials/videos/x54-how-to-create-ajax-flicker-free-pages-in-aspnet.aspx

Thank you for posting at Dotnetfunda
[Administrator]

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mahesh_Chs on: 7/29/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Try this.....


protected void ddlpwdques_OnSelectedIndexChanged(object sender,EventArgs e )
{

txtPassword.Attributes.Add("value", txtPassword.Text);
//remaing code
}

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Maneel on: 7/30/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
In your dropdownlist you can use "onchange" client side event. It is just like OnSelectedIndexChanged but used on client side. If you have no code in server side means it will be useful.

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response