페이지가 예상대로 작동하고 버튼이 비활성화되고 로딩 표시기가 표시되지만 OnClick 이벤트가 호출되지 않습니다. 나는 비교적 자바 스크립트에 대한 경험이없고 이것이 왜 작동하지 않는지에 대한 답을 찾을 수없는 것 같습니다.
Disable () 메서드가 발생하고 true를 반환하면 OnClick 메서드가 호출되어 다시 게시되고 버튼이 자동으로 다시 활성화됩니다.
아마도 내가이 모든 것을 잘못하고있는 것 같습니다. 도와 주셔서 감사합니다.
<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
<%@ Control Language="c#" Inherits="MyControl"
Codebehind="ThisControl.ascx.cs"%>
<div class="Form" style="width: 100%">
<img id="imgLoading" src="images/GridImages/spinner.gif" style="display:none" alt="loading..." />
<ol>
<li>
<asp:Button ID="FirstButton" CssClass="btn" runat="server" Text="First Press Me"
OnClick="First_Click" OnClientClick="this.value='Please Wait...'; needToConfirm=false; return Disable(); "/>
<span>
<asp:Button ID="SecondButton" CssClass="btn" runat="server" Text="Second Press Me"
OnClick="Second_Click" OnClientClick="this.value='Please Wait...'; needToConfirm=false; return Disable(); "/>
</span>
</li>
</ol>
<script type="text/javascript">
function Disable() {
document.getElementById('<%=FirstButton.ClientID %>').disabled = true;
document.getElementById('<%=SecondButton.ClientID %>').disabled = true;
setTimeout('UpdateImg()', 0);
return true;
}
function UpdateImg() {
$('#imgLoading').show();
var img = document.getElementById('imgLoading');
img.src = 'images/GridImages/spinner.gif';
}
</script>
</div>
여기 에서 답을 찾았습니다 .
"UseSubmitBehavior = False"를 추가했으며 OnClick 이벤트가 제대로 호출되었습니다.
분명히 asp는 버튼의 비활성화를 즉시 존중하고 이벤트 발생을 실패시킵니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다