Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > composite control does not fire event

Reply
Thread Tools

composite control does not fire event

 
 
Patrick
Guest
Posts: n/a
 
      07-15-2005
Hi

I have an aspx-page, where I load my custom-control (see below). The problem
I have is that the event does not fire. I really cant figure out why. Just
to know, I derive from System.Web.UI.Control, becaues later on I want to add
some more controls, but first I have to solve this problem.

Has someone an idea?

Thanks
Patrick


*************** default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
Control ctrl = new Mycustomcontrol();
this.form1.Controls.Add(ctrl);
}


*************** Mycustomcontrol.cs
public class Mycustomcontrol: System.Web.UI.Control
{
private Button bt;

protected override void CreateChildControls()
{

bt = new Button();
bt.Text = "test";
this.Controls.Add(bt);
bt.Click += new EventHandler(bt_Click);
}

protected void bt_Click(object sender, EventArgs e)
{
System.Web.HttpContext.Current.Response.Write("but ton was clicked");
}

}


 
Reply With Quote
 
 
 
 
Patrick
Guest
Posts: n/a
 
      07-19-2005
no, it was easier, just had to implement the INamingContainer Interface, now
it works


"intrader" <> schrieb im Newsbeitrag
news. ..
> On Fri, 15 Jul 2005 21:28:08 +0200, Patrick wrote:
>
>> Hi
>>
>> I have an aspx-page, where I load my custom-control (see below). The
>> problem
>> I have is that the event does not fire. I really cant figure out why.
>> Just
>> to know, I derive from System.Web.UI.Control, becaues later on I want to
>> add
>> some more controls, but first I have to solve this problem.
>>
>> Has someone an idea?
>>
>> Thanks
>> Patrick
>>
>>
>> *************** default.aspx.cs
>> protected void Page_Load(object sender, EventArgs e)
>> {
>> Control ctrl = new Mycustomcontrol();
>> this.form1.Controls.Add(ctrl);
>> }
>>
>>
>> *************** Mycustomcontrol.cs
>> public class Mycustomcontrol: System.Web.UI.Control
>> {
>> private Button bt;
>>
>> protected override void CreateChildControls()
>> {
>>
>> bt = new Button();
>> bt.Text = "test";
>> this.Controls.Add(bt);
>> bt.Click += new EventHandler(bt_Click);
>> }
>>
>> protected void bt_Click(object sender, EventArgs e)
>> {
>> System.Web.HttpContext.Current.Response.Write("but ton was
>> clicked");
>> }
>>
>> }

> I am assuming that you don't see the "button was clicked" message.
> Is bubbling to the page your problem?
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fire a client event from a composite control Joe Abou Jaoude ASP .Net Building Controls 1 07-04-2007 04:26 AM
composite control does not fire event Patrick ASP .Net Web Controls 3 07-18-2005 03:59 PM
Losing Composite Control property that another Composite Control ... Chad ASP .Net Building Controls 0 02-01-2005 09:01 PM
Possible to create a composite control that has a child control that is a validator that validates the composite control itself? Jonathan Eric Miller ASP .Net Building Controls 2 07-22-2004 10:58 PM
Composite Control datagrid event does not fire C. Ramsey ASP .Net Building Controls 1 09-15-2003 08:31 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57