代码触发事件
1 指定控件ID
<Buttons>
<ext:Button ID="btnLogin" runat="server" Text="Login" Icon="Accept">
</ext:Button>
2 指定后台可以访问的控件
Protected WithEvents btnLogin As Global.Ext.Net.Button
3 在后台定义事件具体代码
Private Sub btnLogin_DirectClick(sender As Object, e As Ext.Net.DirectEventArgs) Handles btnLogin.DirectClick
Dim strUserCode As String
Dim strPWD As String
Dim objUser As prjECWSDB.MODEL.clstblUser
strUserCode = txtUsername.Text.Trim
strPWD = txtPassword.Text.Trim
objUser = CheckLogin(strUserCode, strPWD)
If Not objUser Is Nothing Then
Session("ectblUser") = objUser
Session.Timeout = 6000
Response.Redirect("frmECDesktop.aspx")
Else
Ext.Net.X.Msg.Alert("Login", "登入名稱或密碼錯誤!").Show()
End If
End Sub
后台页面利用句柄调用函数
1 后台函数的定义
<DirectMethod>
Public Sub ecItemOnHand2()
clsExtNetModule.ExtNetDesktop_CreateWin(Desktop3y, "modItemOnHandQuery2", 1200, 800, "frmItemOnHandSummaryView2.aspx")
End Sub
2 后台函数的调用
function() {#{DirectMethods}.ecItemOnHand2()
前台页面利用句柄调用函数
(1)
前面页面函数的定义
var tile = function ()
{
Ext.ComponentQuery.query('desktop')[0].tileWindows();
};
(2)
前台页面函数的调用
<ext:Button ID="btnTitleWin" runat="server" Handler="tile" Icon="ApplicationTileVertical">
<QTipCfg Text="Tile windows" />
3 定义动态生成的按钮的单击事件
(1)
objButton.Handler = "function(){#{DirectMethods}.myButton_click();}"
(2)
<DirectMethod>
Public Sub myButton_click()
Dim id As String
Dim name As Integer
Dim GridPanelID As String
Dim sm As New Ext.Net.RowSelectionModel
'Ext.Net.X.Msg.Alert("welcome", "hello world").Show()
GridPanelID = CType(Session("GridPanel"), GridPanel).ID
sm = CType(Session("GridPanel"), GridPanel).GetSelectionModel
'id = sm.SelectedRows(0).RecordID
name = CType(Session("id"), Integer)
Ext.Net.X.Msg.Alert("welcome", id & name).Show()
End Sub
(3) 注释:需要添加EXT.NET命名空间的引用,而且定义的函数的属性应该为 Public