我有一个叫Default.aspx的网页。她是个中继器:
<asp:Repeater ID="repBudget" runat="server" OnItemCreated="ItemCreated">
<ItemTemplate>
<div>
<label>
<%# Eval("NameCountry") %>
</label>
<asp:TextBox ID="tbBudget" runat="server" TextMode="Number"
onKeyUp ="tbBudgetKeyPressed(this, LowValue);"
AutoPostBack = "false"
min='<%#Eval("LowValue") %>' max='<%#Eval("TopValue") %>'
pattern="^[0-9]*$" required step="1" Text='<%#Eval("Filing") %>' />
</div>
</ItemTemplate>
</asp:Repeater>
我在客户那边做了一个手柄:
function tbBudgetKeyPressed(ida, minvalue) {
alert(ida.value);
document.getElementById(ida.id).blur();
document.getElementById(ida.id).focus();
}
我的问题是如何传递参数max和min
从asp:文本框,它在中继器到tbBudgetKeyPressed。谢谢
发布于 2018-11-27 12:17:16
如果您知道id,您可以找到属性。我不知道LowValue
在KeyUp中是什么,所以我在没有它的情况下做了这个例子。
onKeyUp="tbBudgetKeyPressed(this)"
然后是JS
<script type="text/javascript">
function tbBudgetKeyPressed(ida) {
var min = $('#' + ida.id).attr('min');
var max = $('#' + ida.id).attr('max');
console.log(min);
console.log(max);
}
</script>
或者如果您不使用jQuery
var min = document.getElementById(ida.id).getAttribute('min');
var max = document.getElementById(ida.id).getAttribute('max');
https://stackoverflow.com/questions/53499270
复制相似问题