谢楼上的, 80分归你了,晚上定结!不过我还想问问有没有其他方法,如通过事件的参数EventArgs??
此问分数另计!

解决方案 »

  1.   

    if your control implements IPostBackEventHandler interface, then ASP.NET call its RaisePostBackEvent, the second parameter from __doPostBack is passed as the  paramemtervoid RaisePostBackEvent( string eventArgument)
    {
    //....
    }
      

  2.   

    看过这个例子,不过不是太理解, 你能解释一下吗?
    aspx 页中可以建立这个类的实例吗?
    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>");
       }
    }
      

  3.   

    writer.Write("<a href=\"javascript:" + Page.GetPostBackEventReference(this,"inc") + "\">Increase Number</a>"); ===>output something like, ctl10 is the UniqueID of your control
    <a href="javascript:__doPostBack('ctl10','inc')">Increase Number</a>when the post is submitted, asp.net will get "ctl10" from Request.Form["__EVENTTARGET"], then it will check if ctl10 implements IPostBackEventHandler, if it is, it will call your control's RaisePostBackEvent('inc')