嘿,我有一个条款和条件文本区域,下面有一个滚动条和一个普通的ASP.NET按钮。
我想知道如何在用户滚动到条款和条件结束之前禁用此按钮。
答案 0 :(得分:2)
这是客户端最好的成就 - 你是否已经使用了诸如jQuery之类的库?
设置以下内容是一种享受:
<asp:TextBox runat="server" id="termsConditions"
TextMode="MultiLine" Rows="10" Columns="50">
Lots of text here[...]
</asp:textbox>
<asp:button runat="server" id="accept" text="Accept" />
<script type="text/javascript">
// Using jQuery, other options are available
// pick up the button, and disable it, keeping the button for later.
// Note the use of the ClientID property of the ASP.NET controls - this allows
// us to cleanly pick up the client side id of the objects.
var button = $("#<%= accept.ClientID %>");
button.attr("disabled", "disabled");
// pick up the textarea.
var terms = $("#<%= termsConditions.ClientID %>");
// bind to the textarea's scroll event
terms.scroll(
function () {
// Compare the scollHeight (the complete height of the textarea), with the
// combination of the current position (scrollTop) and the offsetHeight.
if (terms[0].scrollHeight < (terms[0].offsetHeight + terms[0].scrollTop)) {
// Re-enable the button
button.attr("disabled", null);
}
});
</script>
答案 1 :(得分:0)
我们的不是理由,这是一个例子