1

I am developing small web application in which I am having one button which is used for editing and named ButtonEdit.

I am setting this button Enabled=false at design time so, when the page is rendered the button is disabled.

Now when the checkbox is checked I am making the button enabled using 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.

I am having proper code in my form written with 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?

3
  • If the button is disabled, you can not click the button... Commented Aug 25, 2014 at 14:11
  • @epascarello after enabling the button from javascript i am trying to click the button and fire some event or script to execute. Commented Aug 25, 2014 at 14:12
  • perhaps it would benefit you to show all relevant code this is not a difficult thing to do especially if you are familiar with call javascript functions within your c# code to invoke a C# Method @Dalorzo answer should be straight forward enough now perhaps you are need Dalorzo to show you how to write the javascript delcaration..?? SHOW YOUR JAVASCRIPT FUnction Please Commented Aug 25, 2014 at 14:18

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

2 Comments

Please put some explanation i am unable to understand how it works and what will happen? Still i have not tried your solution.
Still javascript is not called after the button is enabled by removing attribute.
0
protected void Button1_Click(object sender, EventArgs e)
{
    Response.Write("Clicked!");
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.