Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm using the customvalidator in my web page. I get the following error when I try to run the web page:

 

Unable to find control id 'lstRider' referenced by the 'ControlToValidate' property of 'cvRiders'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

 

Exception Details: System.Web.HttpException: Unable to find control id 'lstRider' referenced by the 'ControlToValidate' property of 'cvRiders'

 

 

Here is part of my HTML that is of concern:

<asp:TemplateColumn HeaderText="Riders">

<ItemTemplate>

<asp:listbox AutoPostBack="False" BackColor="#ffffff" id="lstRider" runat="server" Rows="1" DataSource="<%# DsRider1 %>" Enabled="True" SelectionMode="Multiple" DataTextField="UserName" DataValueField="UserID" />

</asp:listbox>

</ItemTemplate>

</asp:TemplateColumn>

</asp:datagrid><asp:customvalidator id="cvRiders" style="Z-INDEX: 104; LEFT: 136px; POSITION: absolute; TOP: 88px" runat="server"

display="Static" OnServerValidate="lstRiderValidation" ErrorMessage="Riders has a maximum selection of 2" ControlToValidate="lstRider"></asp:customvalidator>

 

 

This is what I have in my code-behind:

 

Sub lstRiderValidation(ByVal source As Object, ByVal arguments As ServerValidateEventArgs) Handles cvRiders.ServerValidate

 

Dim strSelectionArray() As String = arguments.Value.Split(",")

 

If strSelectionArray(2).Length > 0 Then 'Max 2 selections

arguments.IsValid = False

Else

arguments.IsValid = True

End If

 

End Sub

 

How can I get the customvalidator to recognize my control? I know it's probably because the control is an itemtemplate...

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

Posted
I just included the validator control inside my itemtemplate....

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

Posted

Robby, no I didn't. I didn't get a chance yet to test out the validation, but I am able to display the web page now without a problem.

 

Is there some link or small sample that you could point me to where I can take care of this?

 

Shouldn't the code in my lstRiderValidation event handle this validation?

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...