如何验证父页面上的用户控件文本框值?我有以下代码,但它无法找到控件。我检查了IE查看源(HTML),此控件呈现为
ctl00_Management_Initiation_txtTitle_txtInput
如何使用JQuery获取值?请告诉我。
<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" />
答案 0 :(得分:1)
if($("#<%= txtTitle.TextInputClientID %>").val().length == 0) {
严重缺乏关闭括号,&#34;}&#34;和&#34;)&#34;在你的javascript中。
向您的用户控件添加属性:
public string TextInputClientID { get { return txtInput.ClientID; } }