2
事件母版控制我有我的母版頁上LinkButton
,並希望在我的內容頁用它做,手柄點擊內容頁
所以我寫這樣的代碼在我的頁面加載:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("UserID") Is Nothing Then
Session("UserID") = Request.ServerVariables("LOGON_USER").Replace("INA\", "")
End If
Me.lbleMessage.Text = ""
Dim lblUaname As Label = DirectCast(Master.FindControl("lblUname"), Label)
lblUaname.Text = Session("UserID").ToString
Dim testlinkbutton As LinkButton = DirectCast(Master.FindControl("LinkButton1"), LinkButton)
testlinkbutton.Click += New EventHandler(AddressOf LinkButton1_Click)
If Not IsPostBack Then
Me.lbleMessage.Text = ""
If Session("UserID") <> "svaldano" Then
'If CAuth.AuthUser(Session("UserID"), "20") Then
'Else
' Response.Redirect("login.aspx")
'End If
FillDataWO()
FillDataTC()
ElseIf Not (Session("Username") Is Nothing) Then
'If CAuth.AuthUser(Session("Username"), "20") Then
'Else
' Response.Redirect("login.aspx")
'End If
If Session("Username") = "sv" Then
FillDataWO()
FillDataTC()
Else
Response.Redirect("login.aspx")
End If
ElseIf Session("Username") Is Nothing Then
Session("UserID") = Request.ServerVariables("LOGON_USER").Replace("BMJAKARTA\", "")
Response.Redirect("login.aspx")
End If
End If
End Sub
,但給我一個錯誤的行testlinkbutton.Click += New EventHandler(AddressOf LinkButton1_Click)
,
Public Event Click(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
所以這是真的,我不能用我的代碼?因爲我只是知道而不是
testlinkbutton.Click += New EventHandler(AddressOf LinkButton1_Click)
raiseevent