本文整理汇总了C#中System.Web.UI.Page.GetPostBackEventReference方法的典型用法代码示例。如果您正苦于以下问题:C# Page.GetPostBackEventReference方法的具体用法?C# Page.GetPostBackEventReference怎么用?C# Page.GetPostBackEventReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.Page
的用法示例。
在下文中一共展示了Page.GetPostBackEventReference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: if
public class MyControl1 : Control, 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 int Number
{
get
{
if ( ViewState["Number"] !=null )
return (int) ViewState["Number"];
return 50;
}
set
{
ViewState["Number"] = value;
}
}
// Implement the RaisePostBackEvent method from the
// IPostBackEventHandler interface. If 'inc' is passed
// to this method, it increases the Number property by one.
public void RaisePostBackEvent(string eventArgument)
{
Number = Number + 1;
}
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void Render(HtmlTextWriter writer)
{
// 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(this) + "\">Increase Number</a>");
}
}
示例2: if
public class MyControl : Control, 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 int Number
{
get
{
if ( ViewState["Number"] !=null )
return (int) ViewState["Number"];
return 50;
}
set
{
ViewState["Number"] = value;
}
}
// 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.
public void RaisePostBackEvent(string eventArgument)
{
if ( eventArgument == "inc" )
Number = Number + 1;
if ( eventArgument == "dec" )
Number = Number - 1;
}
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void Render(HtmlTextWriter writer)
{
// 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(this,"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(this,"dec") + "\">Decrease Number</a>");
}
}