J
jobs
RE: changepassword template.. findcontrol on textboxes?
I've done this before for formviews and grdviews.. but somehow i am
unable to test the value of changepassword text box ?
Getting this error:
Object reference not set to an instance of an object.
my simple code below . I understand I'm circumventing the delivered
Validators and error message literal. Reason is I want my master page
error popup for that.
<%@ Page Language="VB" AutoEventWireup="false" MasterPageFile="~/Main/
MasterPage.master"
CodeFile="ChangePassword.aspx.vb" Inherits="Service_test" %>
<%@ MasterType virtualpath="~/Main/MasterPage.master" %>
<asp:Content ID="other" ContentPlaceHolderID="Content1"
runat="Server">
<h3>
Change Password
</h3>
<div style="position: relative; left: 20px">
<asp:ChangePassword Width="500px"
ID="ChangePassword1" runat="server" >
<ChangePasswordTemplate>
<br />
<asp:Label ID="CurrentPasswordLabel" skinid="retailer"
runat="server" AssociatedControlID="CurrentPassword">Password:</
asp:Label>
<br />
<asp:TextBox ID="CurrentPassword" skinid="Retailer"
runat="server" CssClass="RTTextbox" TextMode="Password"></asp:TextBox>
<br />
<asp:Label ID="NewPasswordLabel" skinid="Retailer"
runat="server" AssociatedControlID="NewPassword">New Password:</
asp:Label>
<br />
<asp:TextBox ID="NewPassword" skinid="Retailer"
runat="server" TextMode="Password"></asp:TextBox>
<br />
<asp:Label ID="ConfirmNewPasswordLabel" SkinID="Retailer"
runat="server" AssociatedControlID="ConfirmNewPassword">Confirm New
Password:</asp:Label>
<br />
<asp:TextBox ID="ConfirmNewPassword" runat="server"
skinid="Retailer" TextMode="Password"></asp:TextBox>
<br />
<asp:Literal ID="FailureText" runat="server" visible="False"
EnableViewState="False"></asp:Literal>
<br />
<asp:Button ID="ChangePasswordPushButton" runat="server"
skinid="Retailer" CommandName="ChangePassword" Text="Change Password"
ValidationGroup="ChangePassword1"
OnClick="ChangePasswordPushButton_Click" />
<asp:Button ID="CancelPushButton" SkinID="Retailer"
runat="server" BackColor="#0272A6" BorderColor="Gray"
CausesValidation="False" CommandName="Cancel"
Text="Cancel" />
</ChangePasswordTemplate>
</asp:ChangePassword>
</div>
</asp:Content>
Imports system.web.security.membership
Imports system.web.security.Roles
Partial Class Service_test
Inherits System.Web.UI.Page
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
If CType(ChangePassword1.FindControl("FailureText"),
Literal).Text <> "" Then
Master.ErrorMsg = "ERROR: " +
CType(ChangePassword1.FindControl("FailureText"), Literal).Text
Return
End If
End Sub
Protected Sub ChangePasswordPushButton_Click(ByVal sender As
Object, ByVal e As System.EventArgs)
If CType(ChangePassword1.FindControl("NewPassword"),
TextBox).Text <>
CType(ChangePassword1.FindControl("ConfirmNewPassword"), TextBox).Text
Then
Master.ErrorMsg = "ERROR: Passwords do not match."
Return
End If
End Sub
End Class
Thanks for any help or information!
I've done this before for formviews and grdviews.. but somehow i am
unable to test the value of changepassword text box ?
Getting this error:
Object reference not set to an instance of an object.
my simple code below . I understand I'm circumventing the delivered
Validators and error message literal. Reason is I want my master page
error popup for that.
<%@ Page Language="VB" AutoEventWireup="false" MasterPageFile="~/Main/
MasterPage.master"
CodeFile="ChangePassword.aspx.vb" Inherits="Service_test" %>
<%@ MasterType virtualpath="~/Main/MasterPage.master" %>
<asp:Content ID="other" ContentPlaceHolderID="Content1"
runat="Server">
<h3>
Change Password
</h3>
<div style="position: relative; left: 20px">
<asp:ChangePassword Width="500px"
ID="ChangePassword1" runat="server" >
<ChangePasswordTemplate>
<br />
<asp:Label ID="CurrentPasswordLabel" skinid="retailer"
runat="server" AssociatedControlID="CurrentPassword">Password:</
asp:Label>
<br />
<asp:TextBox ID="CurrentPassword" skinid="Retailer"
runat="server" CssClass="RTTextbox" TextMode="Password"></asp:TextBox>
<br />
<asp:Label ID="NewPasswordLabel" skinid="Retailer"
runat="server" AssociatedControlID="NewPassword">New Password:</
asp:Label>
<br />
<asp:TextBox ID="NewPassword" skinid="Retailer"
runat="server" TextMode="Password"></asp:TextBox>
<br />
<asp:Label ID="ConfirmNewPasswordLabel" SkinID="Retailer"
runat="server" AssociatedControlID="ConfirmNewPassword">Confirm New
Password:</asp:Label>
<br />
<asp:TextBox ID="ConfirmNewPassword" runat="server"
skinid="Retailer" TextMode="Password"></asp:TextBox>
<br />
<asp:Literal ID="FailureText" runat="server" visible="False"
EnableViewState="False"></asp:Literal>
<br />
<asp:Button ID="ChangePasswordPushButton" runat="server"
skinid="Retailer" CommandName="ChangePassword" Text="Change Password"
ValidationGroup="ChangePassword1"
OnClick="ChangePasswordPushButton_Click" />
<asp:Button ID="CancelPushButton" SkinID="Retailer"
runat="server" BackColor="#0272A6" BorderColor="Gray"
CausesValidation="False" CommandName="Cancel"
Text="Cancel" />
</ChangePasswordTemplate>
</asp:ChangePassword>
</div>
</asp:Content>
Imports system.web.security.membership
Imports system.web.security.Roles
Partial Class Service_test
Inherits System.Web.UI.Page
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
If CType(ChangePassword1.FindControl("FailureText"),
Literal).Text <> "" Then
Master.ErrorMsg = "ERROR: " +
CType(ChangePassword1.FindControl("FailureText"), Literal).Text
Return
End If
End Sub
Protected Sub ChangePasswordPushButton_Click(ByVal sender As
Object, ByVal e As System.EventArgs)
If CType(ChangePassword1.FindControl("NewPassword"),
TextBox).Text <>
CType(ChangePassword1.FindControl("ConfirmNewPassword"), TextBox).Text
Then
Master.ErrorMsg = "ERROR: Passwords do not match."
Return
End If
End Sub
End Class
Thanks for any help or information!