So I want to iterate through a content and let say this content has 4 textbox
所以我想迭代一个内容,并说这个内容有4个文本框
<asp:Content runat="server" ID="FeaturedContent" ClientIDMode="Static" ContentPlaceHolderID="MainContent" class="Tester">
Property ID:
<asp:TextBox ID="PersonIDLabel1" runat="server" class="PersonalIDLabel1" onBlur="textBlur(event)" />
<br />
LastName:
<asp:TextBox ID="LastNameTextBox" runat="server" ClientIDMode="Static" onBlur="textBlur(event);" />
<br />
FirstName:
<asp:TextBox ID="FirstNameTextBox" runat="server" ClientIDMode="Static" onBlur="textBlur(event);"/>
<br />
Appraisal Comapny:
<asp:TextBox ID="HireDateTextBox" runat="server" ClientIDMode="Static" onBlur="textBlur(event);"/>
<br />
Appraisal value:
<asp:TextBox ID="EnrollmentTextBox" runat="server" ClientIDMode="Static" onBlur="textBlur(event);"/>
<br />
and I want to use jquery to get all the value if the textbox, here is my code:
并且我想使用jquery来获取文本框的所有值,这里是我的代码:
$("#FeaturedContent").each(function (index) {
console.log($(this).val());
});
I also tried
我也试过了
$(".Tester").each(function (index) {
console.log($(this).val());
});
$("#MainContent").each(function (index) {
console.log($(this).val());
});
$("#Content").each(function (index) {
console.log($(this).val());
});
$("#TextBox").each(function (index) {
console.log($(this).val());
});
any ideas? Can I even get ASP tags?
有任何想法吗?我甚至可以获得ASP标签吗?
3 个解决方案
#1
2
IIRC asp:Content
server control does not produce html for itself. Simply wrap what is inside of this control in a div:
IIRC asp:内容服务器控件不会为自己生成html。只需在div中包装此控件内部的内容:
<asp:Content runat="server" ID="FeaturedContent" ClientIDMode="Static" ContentPlaceHolderID="MainContent" class="Tester">
<div id="wrapper">
Property ID:
<asp:TextBox ID="PersonIDLabel1" runat="server" class="PersonalIDLabel1" onBlur="textBlur(event)" />
<br />
...
</div>
</asp:Content>
and do:
并做:
$("#wrapper input").each(function (index) {
console.log($(this).val());
});
#2
0
Try this
尝试这个
$("#<%=FeaturedContent.ClientID%> input").each(function () {
console.log($(this).val());
});
#3
0
Maybe you can use something like that in your javascript function :
也许你可以在你的javascript函数中使用类似的东西:
var myAnswers[] = $('.class').Content().ToArray();
#1
2
IIRC asp:Content
server control does not produce html for itself. Simply wrap what is inside of this control in a div:
IIRC asp:内容服务器控件不会为自己生成html。只需在div中包装此控件内部的内容:
<asp:Content runat="server" ID="FeaturedContent" ClientIDMode="Static" ContentPlaceHolderID="MainContent" class="Tester">
<div id="wrapper">
Property ID:
<asp:TextBox ID="PersonIDLabel1" runat="server" class="PersonalIDLabel1" onBlur="textBlur(event)" />
<br />
...
</div>
</asp:Content>
and do:
并做:
$("#wrapper input").each(function (index) {
console.log($(this).val());
});
#2
0
Try this
尝试这个
$("#<%=FeaturedContent.ClientID%> input").each(function () {
console.log($(this).val());
});
#3
0
Maybe you can use something like that in your javascript function :
也许你可以在你的javascript函数中使用类似的东西:
var myAnswers[] = $('.class').Content().ToArray();