Reputation: 6609
I am using telerik RadTextBox
inside asp.net
User Control page.
I have writen below Jquery
validation code inside main content page as shown below, I am trying to set RadText box name
attribute as static inside User Control so that I can use it in Main Content page.
User Control page
<telerik:RadTextBox ID="txtProductPrice" ClientID="txtProductPrice"
runat="server" ClientIDMode="Static" />
Main Content Page:
$("#aspnetForm").validate({
rules: {
ctl00$ContentPlaceHolder1$ucUserInfoI$txtProductPrice: {
required: true,
number: true,
maxlength: 5
},
}
});
I have used dynamically generated name attribute to validate the textbox, which looks ugly.
Since RadTexBox is in UserControl page , I am not able to use RadTexBox with UniqueID
in main content page as below:
$("#aspnetForm").validate({
rules: {
<%=txtProductPrice.UniqueID %>:{
required: true,
number: true,
maxlength: 5
},
}
});
Any idea how to I can use RadTexBox with UniqueID
in main content page ?
Any help would be great.
Upvotes: 0
Views: 345
Reputation: 411
These steps can prove helpful to you:
1. For client-side logic, you can try using <%=txtProductPrice.ClientID %>
instead of UniqueID.
2. Telerik controls are complex server and script controls and you should not use ClientIDMode="Static" with them. Details
3. Make sure you have the following setting in your web.config file as suggested by Sparky:
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
Here are some Details and More Details.
4. You can always use the $telerik.findControl
method to manually access the RadTextBox and execute your custom logic. Details
Upvotes: 1