本文整理汇总了VB.NET中System.Web.UI.Page.GetPostBackEventReference方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Page.GetPostBackEventReference方法的具体用法?VB.NET Page.GetPostBackEventReference怎么用?VB.NET Page.GetPostBackEventReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.Page
的用法示例。
在下文中一共展示了Page.GetPostBackEventReference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: MyControl1
Public Class MyControl1
Inherits Control
Implements IPostBackEventHandler
' Create an integer property that is displayed when
' the page that contains this control is requested
' and save it to the control's ViewState property.
Public Property Number() As Integer
Get
If Not (ViewState("Number") Is Nothing) Then
Return CInt(ViewState("Number"))
End If
Return 50
End Get
Set
ViewState("Number") = value
End Set
End Property
' Implement the RaisePostBackEvent method from the
' IPostBackEventHandler interface. If inc is passed
' to this method, it increases the Number property by one.
Public Sub RaisePostBackEvent(eventArgument As String) Implements IPostBackEventHandler.RaisePostBackEvent
Number = Number + 1
End Sub
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub Render(writer As HtmlTextWriter)
' Converts the Number property to a string and
' writes it to the containing page.
writer.Write(("The Number is " + Number.ToString() + " ("))
' Uses the GetPostBackEventReference method to pass
' inc to the RaisePostBackEvent method when the link
' this code creates is clicked.
writer.Write(("<a href=""javascript:" + Page.GetPostBackEventReference(Me) + """>Increase Number</a>"))
End Sub
End Class
示例2: MyControl
Public Class MyControl
Inherits Control
Implements IPostBackEventHandler
' Create an integer property that is displayed when
' the page that contains this control is requested
' and save it to the control's ViewState property.
Public Property Number() As Integer
Get
If Not (ViewState("Number") Is Nothing) Then
Return CInt(ViewState("Number"))
End If
Return 50
End Get
Set
ViewState("Number") = value
End Set
End Property
' Implement the RaisePostBackEvent method from the
' IPostBackEventHandler interface. If inc is passed
' to this method, it increases the Number property by one.
' If dec is passed to this method, it decreases the
' Number property by one.
Sub RaisePostBackEvent(eventArgument As String) Implements IPostBackEventHandler.RaisePostBackEvent
If eventArgument = "inc" Then
Number = Number + 1
End If
If eventArgument = "dec" Then
Number = Number - 1
End If
End Sub
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub Render(writer As HtmlTextWriter)
' Converts the Number property to a string and
' writes it to the containing page.
writer.Write(("The Number is " + Number.ToString() + " ("))
' Uses the GetPostBackEventReference method to pass
' inc to the RaisePostBackEvent method when the link
' this code creates is clicked.
writer.Write(("<a href=""javascript:" + Page.GetPostBackEventReference(Me, "inc") + """>Increase Number</a>"))
writer.Write(" or ")
' Uses the GetPostBackEventReference method to pass
' dec to the RaisePostBackEvent method when the link
' this code creates is clicked.
writer.Write(("<a href=""javascript:" + Page.GetPostBackEventReference(Me, "dec") + """>Decrease Number</a>"))
End Sub
End Class