Hi friends,
I want to know that the method which must be overridden in a custom control?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Anuja PawarPosted Dec 20, 2011, 6:05 AM
see this example, the Render method uses the HtmlTextWriter object passed in as a parameter to write the string held in the Text property
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace CustomControls
{
[DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1 runat=server>{0}:WebCustomControl1>")]
public class WebCustomControl1 : System.Web.UI.WebControls.WebControl {
private string text;
[Bindable(true), Category("Appearance"), DefaultValue("")]
public string Text {
get {
return text;
}
set {
text = value;
} }
protected override void Render(HtmlTextWriter output)
{
output.Write(Text);
}
}
}
Satyapriya NayakPosted Dec 19, 2011, 12:34 PM
The key method of the custom control is Render. This method is declared in the base class, and must be overridden in your derived class if you wish to take control of rendering to the page.
Thanks