本文整理匯總了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>");
}
}