On the. NET page, you must have a button. Click it to set the disabled attribute of this button and trigger server events. The Code is as follows:
HTML:
<Form ID = "form1" runat = "server">
<Asp: button id = "button1" runat = "server" onclick = "button#click" text = "button" onclientclick = "This. Disabled = true; return true;"/>
</Form>
C #
Protected void button#click (Object sender, eventargs E)
{}
But the problem is that he only triggered the client event, and the server event was not executed at all.
I checked the information. After usesubmitbehavior = "false" is added, client events can be triggered first, the disabled attribute can be set, and server events can be executed.
However, after the server event is executed, the property disabled is changed to enabled again.
Finally, to meet the requirements, simply set enabled on the server side. Then, the client can use a required item to trigger and then clear the property disabled of the button.
The complete code is as follows:
JS Code:
Function display1 ()
{
Document. getelementbyid ("<% = button1.clientid %>"). removeattribute ("disabled ");
}
HTML code:
<Form ID = "form1" runat = "server">
<Input type = "text" runat = "server" onchange = "display1 ()"/>
<Asp: button id = "button1" runat = "server" onclick = "button#click" text = "button"/>
</Form>
C # code:
Protected void button#click (Object sender, eventargs E)
{
This. button1.enabled = false;
}