Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
ASP .Net
ASP .Net Building Controls
Possible to validate between INamingContainers in 2.0?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Teemu Keiski, post: 4257620"] It should be if you assign UniqueID to the ControlToValidate property. As validator uses FindControl to locate the control to be validated, it can find it on other naming containers if the given id is unique id (exposing the full containment hierarchy of the control) Assuming I have a user control, WebUserConntrol1.ascx and it's code-behind <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="WebUserControl1.ascx.vb" Inherits="CSTestApplication1.WebUserControl1" %> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> Public Partial Class WebUserControl1 Inherits System.Web.UI.UserControl Public ReadOnly Property TheBox() As TextBox Get Return TextBox1 End Get End Property End Class And using it on aspx <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="CSTestApplication1.WebForm1" %> <%@ Register Src="WebUserControl1.ascx" TagName="WebUserControl1" TagPrefix="uc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/URL]"> <html xmlns="[URL]http://www.w3.org/1999/xhtml[/URL]" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator> <uc1:WebUserControl1 ID="UC1" runat="server" /> </div> </form> </body> </html> And relevant code to set the UNiqueID Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.RequiredFieldValidator1.ControlToValidate = Me.UC1.TheBox.UniqueID End Sub [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
ASP .Net Building Controls
Possible to validate between INamingContainers in 2.0?
Top