下午所有,按鈕ClickEvent不會被觸發
我有我的網頁上的兩個按鈕,用於鎖定和解鎖一個網頁,以便用戶可以鎖定頁面,編輯此沒有其他用戶能夠訪問記錄,然後解鎖此記錄,以便其他用戶可以編輯此記錄。
我的問題是,按鈕不工作,我不知道爲什麼。我正在使用圖像按鈕,但它看起來像事件沒有被觸發,我不能看到問題,它讓我瘋狂。有人可以看看我的代碼...
<asp:ImageButton ID="btnLock" runat="Server"
AlternateText="Click to lock record" ImageUrl="~/images/lock.png" />
<asp:ImageButton ID="btnUnlock" runat="Server"
AlternateText="Click to unlock record" ImageUrl="~/images/unlock.png" />
<asp:Label ID="lblUserName" runat="server" Font-Bold="True" Font-Size="Medium"
ForeColor="#CC3300"></asp:Label>
<asp:HiddenField ID="hdnIsLockedBy" runat="server" />
'VB Code for lock button...
Protected Sub btnLock_Click(sender As Object, e As System.EventArgs) Handles btnLock.Click
Dim lock As New WeeklyClass
'Check that the Loggedby field is set to null so the user can then lock the record
If String.IsNullOrEmpty(lock.LockedBy) Then
'lock and add the username
lock.LockedBy = User.Identity.Name
'global variable islockedby
hdnIsLockedBy.Value = User.Identity.Name
'AgendaID required as part of the stored procedure
lock.AgendaID = Integer.Parse(lblAgendaNumber.Text)
End If
'Save to the database using the Class DAL and the Stored Procedure
WeeklyClassDAL.LockWeeklyAgenda(lock)
'Display buttons as expected result
btnLock.Visible = False
btnUnlock.Visible = True
' Refreshes fields on the page
Response.Redirect("~/WeeklyAgenda.aspx?Edit=" & lblAgendaNumber.Text)
End Sub
'VB Code for unlock button...
Protected Sub btnUnlock_Click(sender As Object, e As System.EventArgs) Handles btnUnlock.Click
Dim unlock As New WeeklyClass
' Check to see if the system has a username
If hdnIsLockedBy.Value = User.Identity.Name Then
'set the lockedby field to null
unlock.LockedBy = hdnIsLockedBy.Value
'pass the relevent agendaid
unlock.AgendaID = Integer.Parse(lblAgendaNumber.Text)
End If
' save to the database using the Class DAL
WeeklyClassDAL.unLockWeeklyAgenda(unlock)
'Display buttons as expected result
btnLock.Visible = True
btnUnlock.Visible = False
' Refreshes fields on the page
Response.Redirect("~/WeeklyAgenda.aspx?Edit=" & lblAgendaNumber.Text)
End Sub
任何幫助很多appriechiated。我一直在尋找這一點,並且似乎無法找到問題。
問候 貝蒂
考慮重新標題你的問題。它根本沒有意義。 –