Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Composite Controls and Bubbling events

Reply
Thread Tools

Composite Controls and Bubbling events

 
 
Javi
Guest
Posts: n/a
 
      07-08-2003
Iīm programming a composite WebCustomControl called wcc.
I want to hide a button, once it's clicked!!!

And my question is:
Is there any way to execute the OnBubbleEvent(...) method,
before than CreateChildControls() ????
If itīs impossible which is the right way to solve this
problem?

Thankīs

-----------------------

[ToolboxData("<{0}:wcc runat=server></{0}:wcc>")]
public class wcc : System.Web.UI.WebControls.WebControl,
INamingContainer
{
private bool m_bShowButton = true;
private Button cmd = null;

protected override void CreateChildControls()
{
if (this.m_bShowButton)
{
this.cmd = new Button();

this.cmd.ID = "cmd1";
this.cmd.Text = "Command Button";

this.cmd.CommandName = "Click";

Controls.Add (this.cmd);
}
else
System.Diagnostics.Debug.WriteLine
("Button Hidden");
base.CreateChildControls ();
}

protected override bool OnBubbleEvent (object sender,
System.EventArgs e)
{
if (e is CommandEventArgs)
if (((CommandEventArgs) e).CommandName
== "Click")
{
System.Diagnostics.Debug.WriteLine
("OnBubbleEvent");
this.m_bShowButton = false;
return true;
}
return false;
}
}
 
Reply With Quote
 
 
 
 
Ben
Guest
Posts: n/a
 
      07-09-2003
How about:
1. Create the control in CreateChildControls and add it to the Controls
collection as usual
2. Create a property of the control which which stores whether the button
has been clicked, say "ButtonClicked" of type bool, storing it's the in
ViewState.
3. In it's event handler which you added += in CreateChildControls
3. Override OnPreRender of the base class and in this method ButtonClicked
is set to true set the button's Visible property to false!

Ben W

"Javi" <(E-Mail Removed)> wrote in message
news:0b7d01c34548$31929e00$(E-Mail Removed)...
Iīm programming a composite WebCustomControl called wcc.
I want to hide a button, once it's clicked!!!

And my question is:
Is there any way to execute the OnBubbleEvent(...) method,
before than CreateChildControls() ????
If itīs impossible which is the right way to solve this
problem?

Thankīs

-----------------------

[ToolboxData("<{0}:wcc runat=server></{0}:wcc>")]
public class wcc : System.Web.UI.WebControls.WebControl,
INamingContainer
{
private bool m_bShowButton = true;
private Button cmd = null;

protected override void CreateChildControls()
{
if (this.m_bShowButton)
{
this.cmd = new Button();

this.cmd.ID = "cmd1";
this.cmd.Text = "Command Button";

this.cmd.CommandName = "Click";

Controls.Add (this.cmd);
}
else
System.Diagnostics.Debug.WriteLine
("Button Hidden");
base.CreateChildControls ();
}

protected override bool OnBubbleEvent (object sender,
System.EventArgs e)
{
if (e is CommandEventArgs)
if (((CommandEventArgs) e).CommandName
== "Click")
{
System.Diagnostics.Debug.WriteLine
("OnBubbleEvent");
this.m_bShowButton = false;
return true;
}
return false;
}
}


 
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
Composite vs non composite Controls Mike ASP .Net Web Controls 4 03-11-2005 05:47 AM
Bubbling Event in Composite controls Nidhee ASP .Net Building Controls 3 08-02-2004 02:12 PM
Composite control with dynamic composite controls sleigh ASP .Net 1 02-12-2004 06:24 PM
C# UserControl Bubbling events Andy ASP .Net 3 10-28-2003 04:08 PM
Child controls in Composite Controls not firing events David Boike ASP .Net Web Controls 0 08-07-2003 05:39 PM



Advertisments