I have a question about disable button (C#) that I need your help.
in Asp.net (C#), disable the button code:
Button btn = new Button();
btn.click += new EventHandler(btn_click);
btn.Enabled = false;
btn.UseSubmitBehavior = false;
The generated HTML:
<input type=”button” disabled=”disabled”>
The button is disabled until I use firebug and remove the ‘disabled’ property and change the type property to submit (<input type=”submit”>) then user can click on btn and it can perform btn_click method(postback).
How could we prevent this issue? I try to use CommandName (disable, enable) to mark disable button and inside btn_click method, I check if CommandName== “disable” then stop the function but it is very messy.
Thanks for your help.
Van
Client can remove the Disabled attribute but cannot change the control ViewState. On server side you can do that: