[英]Enable button from javascript click event is not working
I am developing small web application
in which I am having one button which is used for editing and named ButtonEdit. 我正在开发小型
web application
,其中有一个用于编辑的按钮,名为ButtonEdit。
I am setting this button Enabled=false
at design time so, when the page is rendered the button is disabled. 我在设计时将此按钮设置为
Enabled=false
,因此,在呈现页面时,该按钮被禁用。
Now when the checkbox is checked I am making the button enabled using javascript
. 现在,当选中此复选框时,我正在使用
javascript
启用按钮。
I used following code. 我用下面的代码。
document.getElementById("ButtonEdit").disabled=false;
And this code works fine and makes my button enabled. 并且此代码可以正常工作并使我的按钮启用。
But when i click on edit button i want to fire some javascript event which is not fired. 但是,当我单击编辑按钮时,我想触发一些未触发的javascript事件。
I am having proper code in my form written with onClientClick=function()
. 我在用
onClientClick=function()
编写的表单中有正确的代码。
But i think as the control is disabled from server side it will not call any event and script. 但是我认为由于从服务器端禁用了该控件,因此不会调用任何事件和脚本。
How can i resolve this problem? 我该如何解决这个问题?
Try this: 尝试这个:
<asp:Button disabled="disabled" ID="myButton" ClientIDMode="Static"
Enabled="false" OnClientClick="return someFunction();" runat="server" Text="Save" />
And then on the client side: 然后在客户端:
document.getElementById('myButton').removeAttribute('disabled'); //or jquery alternative
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("Clicked!");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.