[英]validate user control input value
How to validate user control textbox value on Parent page? 如何在“父”页面上验证用户控件文本框的值? I have the following code but it couldn't find the control.
我有以下代码,但找不到控件。 I have checked IE View Source(HTML) and this control renders as
我已经检查了IE View Source(HTML),并且此控件呈现为
ctl00_Management_Initiation_txtTitle_txtInput
How to get the value using JQuery? 如何使用JQuery获得值? Please let me know.
请告诉我。
<telerik:RadTextBox id="txtInput" runat="server" TextMode="MultiLine" LabelCssClass=""></telerik:RadTextBox>
<asp:image id="ImgRequired1" ImageUrl="../../images/requiredfield.gif" AlternateText="Required Field" Runat="server" Visible=false></asp:image><br />
<script type="text/javascript">
$(document).ready(function () {
$("#<%=btnSave.ClientID %>").click(function () {
var valid = true;
var msg = "Please fill form:\n";
if($("input[id*=txtTitle]").val().length == 0{
msg += "Title is Required!\n";
valid = false;
}
});
});
</script>
<uc1:ControlTextBox ID="txtTitle" runat="server" MaxLength="200" ></uc1:ControlTextBox>
<asp:Button ID="btnSave" name="btnSave" runat="server" Text="Save" />
if($("#<%= txtTitle.TextInputClientID %>").val().length == 0) {
There is serious lack of closing brackets, both "}" and ")" in your javascript. 您的JavaScript严重缺少右括号,“}”和“)”。
Add property to your user control: 将属性添加到您的用户控件:
public string TextInputClientID { get { return txtInput.ClientID; } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.