PC Review


Reply
Thread Tools Rate Thread

changepasswordtemplate.. findcontrol on textboxes?

 
 
jobs
Guest
Posts: n/a
 
      14th Oct 2007
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!

 
Reply With Quote
 
 
 
 
johnadriano@gmail.com
Guest
Posts: n/a
 
      12th Dec 2007
On Oct 15, 3:34 am, jobs <j...@webdos.com> wrote:
> 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!




This should do the trick

Protected Sub ChangePasswordPushButton_Click(ByVal sender As Object,
ByVal e As System.EventArgs)
Dim NewPassword As TextBox =
CType(ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewPassword"),
TextBox)
Dim ConfirmNewPassword As TextBox =
CType(ChangePassword1.ChangePasswordTemplateContainer.FindControl("ConfirmNewPassword"),
TextBox)

If trim(NewPassword.Text) <> trim(ConfirmNewPassword.Text)
Then
Master.ErrorMsg = "ERROR: Passwords do not match."
Return
End If
End Sub


Hope this helps

Regards
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subform with RecordSource and Textboxes - Textboxes not editable? juvi Microsoft Access Form Coding 9 5th Dec 2008 06:34 PM
Must we use FindControl? Jordan S. Microsoft ASP .NET 1 22nd May 2008 05:19 PM
Show Results in TextBoxes, ONLY if All TextBoxes have Data in them =?Utf-8?B?Unlhbkg=?= Microsoft Excel Programming 3 19th Nov 2007 03:30 PM
FindControl =?Utf-8?B?cm9kY2hhcg==?= Microsoft ASP .NET 2 3rd Apr 2007 01:58 PM
Form with cells and TextBoxes...how to TAB to textboxes? Toby Erkson Microsoft Excel Discussion 2 6th Oct 2004 11:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:43 AM.