M
Mehdi
Hi,
I have been working on this for more than a day, with no joy and I was
wondering if someone could help me with this:
I am trying to create a WCC (WebCustomControl) that contains a LinkButton
(server side). I have compiled this WCC, added it to my VS toolbox and it
is working ok, except I need Click event of my WCC. Say if I drag and drop
my WCC from tool box onto a new WebForm and double click on it,
"WebCustomControl1_Click(object sender, System.EventArgs e)" will be
created, but it will not fire from the WebForm. Therefore whatever code i
put in there will not be executed.
I really appreceate if someone could tell me how to do this. Here is my
WebCustomControl code:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace WebControlLibrary1
{
/// <summary>
/// Summary description for WebCustomControl1.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:WebCustomControl1
runat=server></{0}:WebCustomControl1>")]
public class WebCustomControl1 : System.Web.UI.WebControls.LinkButton ,
INamingContainer
{
private System.Web.UI.WebControls.LinkButton _btn;
public WebCustomControl1()
{
this._btn = new LinkButton();
}
[Bindable(false),
Category("Datel")]
public string Text
{
set
{
_btn.Text = value;
}
get
{
return _btn.Text;
}
}
protected override void CreateChildControls()
{
_btn.ID = UniqueID;
_btn.Text = (Text =="" || Text == null) ? "LinkButton1": Text;
_btn.CssClass = CssClass;
Controls.Add(_btn);
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<TABLE id=Table1 cellSpacing=1 cellPadding=1 width=300
border=0 bgColor=yellow>");
writer.Write(" <TR>");
writer.Write(" <TD> </TD>");
writer.Write(" <TD>");
this._btn.RenderControl(writer);
writer.Write(" </TD>");
writer.Write(" <TD> </TD>");
writer.Write(" </TR>");
writer.Write("</TABLE>");
}
}//
}//
//-----------------------------
Thanks for your time.
Regards
Mehdi
I have been working on this for more than a day, with no joy and I was
wondering if someone could help me with this:
I am trying to create a WCC (WebCustomControl) that contains a LinkButton
(server side). I have compiled this WCC, added it to my VS toolbox and it
is working ok, except I need Click event of my WCC. Say if I drag and drop
my WCC from tool box onto a new WebForm and double click on it,
"WebCustomControl1_Click(object sender, System.EventArgs e)" will be
created, but it will not fire from the WebForm. Therefore whatever code i
put in there will not be executed.
I really appreceate if someone could tell me how to do this. Here is my
WebCustomControl code:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace WebControlLibrary1
{
/// <summary>
/// Summary description for WebCustomControl1.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:WebCustomControl1
runat=server></{0}:WebCustomControl1>")]
public class WebCustomControl1 : System.Web.UI.WebControls.LinkButton ,
INamingContainer
{
private System.Web.UI.WebControls.LinkButton _btn;
public WebCustomControl1()
{
this._btn = new LinkButton();
}
[Bindable(false),
Category("Datel")]
public string Text
{
set
{
_btn.Text = value;
}
get
{
return _btn.Text;
}
}
protected override void CreateChildControls()
{
_btn.ID = UniqueID;
_btn.Text = (Text =="" || Text == null) ? "LinkButton1": Text;
_btn.CssClass = CssClass;
Controls.Add(_btn);
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<TABLE id=Table1 cellSpacing=1 cellPadding=1 width=300
border=0 bgColor=yellow>");
writer.Write(" <TR>");
writer.Write(" <TD> </TD>");
writer.Write(" <TD>");
this._btn.RenderControl(writer);
writer.Write(" </TD>");
writer.Write(" <TD> </TD>");
writer.Write(" </TR>");
writer.Write("</TABLE>");
}
}//
}//
//-----------------------------
Thanks for your time.
Regards
Mehdi