On my pages onLoad() function I'm disabling all controls on the page in the following manner
var form = document.getElementById("form1");
var elements = form.elements;
for (var i = 0, len = elements.length; i < len; ++i) {
elements[i].disabled = true;
}
document.getElementById('btnReactivate').disabled = false;
I need one button on the page enabled (btnReactivate above). The problem I'm having is that anytime I click the button and step into the Page_Load event Page.IsPostback is always false And the onclick event in the code behind also doesn't fire. The button is created
<asp:Button runat="server" ID="btnReactivate" Text="btnReactivate" onclick="btnReactivate_Click" width="80px" meta:resourcekey="btnReactivateResource1" />
and the event handler as so
protected void btnReactivate_Click(object sender, EventArgs e)
{}
It's might be also worth mentioning that I've tried disabling the forms elements in a few different ways including just looping through in Input controls rather than all elements
I think this happens because disabled controls are not posted back to the server (thus preventing detection of the postback).
You should make the controls Readonly
. Or re-enable them client-side just before posting.
See http://www.w3.org/TR/html401/interact/forms.html#adef-disabled
Disabled controls cannot be successful.
and, http://www.w3.org/TR/html401/interact/forms.html#adef-readonly
Read-only elements may be successful.