Add submission events for ASP.NET Web Custom Controls
Gu Qinggang prettywolf@vip.sina.com
In the server control provided by Visual Studio.Net, there is a "linkbutton", which looks like a link, which is like a Click submission event like Button. So how do we achieve this feature? The following code tells the implementation of this feature.
1. First create a web custom control project named Demo, and the spatial source code file is named DEMOLINKBUTTON.
2. public class DemoLinkButton: System.Web.UI.WebControls.WebControl, IPostBackEventHandler control class inherits an interface IPostBackEventHandler System.Web.UI.WebControls.WebControl and method of realization: RaisePostBackEvent (string).
3. Modify the Text property.
[Bindable (False),
Category ("APPEARANCE"),
DEFAULTVALUE ("")]
Public String Text
{
get
{
String_text = (string) ViewState ["text"];
Return_Text == NULL? ": _Text;
}
set
{
ViewState ["Text"] = VALUE
}
}
4. JavaScript code submitted to the page registration.
Protected Override Void OnPrender (Eventargs E)
{// Generate the JavaScript function submitted by the page, this function is used to use HyperLink's HREF.