On Oct 26, 11:23 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"gnewsgroup" <gnewsgr...@gmail.comwrote in message
news:11**********************@19g2000hsx.googlegro ups.com...
I've tried out your idea, and it was successful. That's great, but,
what about event-raising and event-consuming amongst user controls?
Say, I want user control A to respond to a click event of user control
B. Public properties won't do the trick, right?
Ah yes - for that, you need delegates:http://www.netomatix.com/development/usercontrols3.aspx
--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
Fantastic. I did write a user control which has a GridView. This
GridView gets populated with customer names retrieved from the
database. The customer names in the GridView are made to be
LinkButtons (in template fields). When such a LinkButton'ed name is
clicked, I want to send the name as a string to the parent control.
Let's call this user control SearchCustomers.ascx.
I followed the example you gave in the link above, and successfully
made the whole thing happen, which kinda excited me. Thank you.
But, I do not want to show SearchCustomers user control in the parent
page until a button is clicked in the parent page.
I have written a Visible property in SearchCustomers.ascx.cs, like so:
private bool visible;
protected void Page_Load(object sender, EventArgs e)
{
if (this.visible)
{
Panel1.Visible = true; // Pane1 holds the GridView.
}
else
{
Panel1.Visible = false;
}
}
public bool Visible
{
get
{
return this.visible;
}
set
{
this.visible = value;
}
}
In ParentPage.aspx's Page_Load, if I say
SearchCustomers1.Visible = true;
This control does show up nicely, but if I attempt to set the Visible
property in the button click event handler like so:
protected void btnSearchCustomers_Click(object s, EventArgs e)
{
SearchCustomers1.Visible = true;
}
The SearchCustomers1 user control does not show up. I kinda suspect
that it is because it has passed the Page_Load event, so the control
cannot be rendered. In any case, how do I show/hide a user control
dynamically? Somehow, I guess this user control has to be recreated /
reloaded, but what do I need to do?
Thank you again if you could share your wisdom.