1. Trigger client events
Copy codeThe Code is as follows:
<Ext: Button ID = "Button1" runat = "server" Text = "hurry up with me">
<Listeners>
<Click Handler = "Greet ()"> </Click>
</Listeners>
</Ext: Button>
<Script type = "text/javascript">
Function Greet (){
Alert ("Hello World! ");
}
</Script>
2. Trigger server events
Copy codeThe Code is as follows:
<Ext: Button ID = "Button1" runat = "server" Text = "hurry up with me">
<DirectEvents>
<Click OnEvent = "MyButtonClickHandler"> </Click>
</DirectEvents>
</Ext: Button>
Protected void MyButtonClickHandler (object sender, DirectEventArgs e)
{
X. Msg. Alert ("Hello", "HelloWorld! ");
}
Note: The client will pop up a message box, and the background function has been executed during debugging. The foreground does not respond and the cause is unknown.
DirectEventArgs can also be replaced with System. EventArgs, but some attributes such as ExtraParams cannot be accessed. The following describes the usefulness of this parameter.
3. Trigger server events and PASS Parameters
Copy codeThe Code is as follows:
<DirectEvents>
<Click OnEvent = "MyButtonClickHandler">
<ExtraParams>
<Ext: Parameter Name = "param1" Value = "value1"> </ext: Parameter>
</ExtraParams>
</Click>
</DirectEvents>
You can use the following method to obtain parameters in the background: e. ExtraParams ["param1"]
|
According to the F12 tool of IE, the parameter is indeed sent to the server. 4. Custom additional attributes Copy codeThe Code is as follows: <Ext: Button ID = "Button1" runat = "server" Text = "hurry up with me"> <Listeners> <Click Handler = "CusProperty (this);"> </Click> </Listeners> <CustomConfig> <Ext: ConfigItem Name = "cusProperty1" Value = "theValue" Mode = "Value"> </ext: ConfigItem> </CustomConfig> </Ext: Button> <Script type = "text/javascript"> Function CusProperty (obj ){ Alert (obj. cusProperty1 ); } </Script>
|
The custom attribute value is obtained successfully.