Asp:按钮未禁用 [英] Asp:Button is not Disabled
本文介绍了Asp:按钮未禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在asp:更新面板中有Button。
< asp:Button ID =btnlaunchrunat =serverCssClass =btn_def marr_5 flt_left Visible =falseOnClick =btnlaunch_ClickOnClientClick =javascript:disableRequestbtn();/>
和我的JavaScript
< script 类型 = text / javascript >
function disableRequestbtn(){
document.getElementById('<% = btnlaunch.ClientID %> ')。disabled = true;
document.getElementById('<% = btnlaunch.ClientID %> ')的removeAttribute( 类)。
alert(gg);
}
< / script >
但未禁用按钮&不要删除Class属性是什么问题。
解决方案
最初你已经使按钮可见= false然后我假设你已经使它可见=真。问题是虽然它现在通过更新面板更新但Javascript可能无法找到它。
尝试通过CSS设置可见性错误,例如
< pre lang =HTML> < asp:button id = btnlaunch runat = server cssclass = btn_def marr_5 flt_left style = display:none; onclick = btnlaunch_Click onclientclick = javascript:disableRequestbtn(); xmlns:asp = < span class =code-keyword>#unknown / >
希望,这有助于:)
I have Button in asp:update panel.
<asp:Button ID="btnlaunch" runat="server" CssClass="btn_def marr_5 flt_left" Visible="false" OnClick="btnlaunch_Click" OnClientClick="javascript:disableRequestbtn();"/>
and My JavaScript
<script type="text/javascript">
function disableRequestbtn() {
document.getElementById('<%= btnlaunch.ClientID %>').disabled = true;
document.getElementById('<%= btnlaunch.ClientID %>').removeAttribute("class");
alert("gg");
}
</script>
but its not disabled button & dont remove Class property whats the problem with it.
解决方案
Initially you have made the button visible=false and then later I assume, you have made it visible=true. Problem is although it is now updated through update panel but Javascript may fail to find it.
Try setting visibility false through CSS like
<asp:button id="btnlaunch" runat="server" cssclass="btn_def marr_5 flt_left" style="display:none;" onclick="btnlaunch_Click" onclientclick="javascript:disableRequestbtn();" xmlns:asp="#unknown" />
Hope, that helps :)
这篇关于Asp:按钮未禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文