| |
GeekInterview.com > Interview Questions > Microsoft > Mixed
| Print | |
Question: Hi,,
I have two User Controls in my web form. When page loads I should view one of those controls. One button is also there in that page When i click that button then i should view other one. How to do that.? I got it by changing AutoEventWireUp="True" of the page... Any other alternative for this?
Please let me know..
Thanks in Advance..
Ravi Majji..
|
| December 12, 2007 17:30:53 |
#2 |
| whirlpool |
Member Since: December 2007 Total Comments: 3 |
RE: Hi,, I have two User Controls in my web form. When page loads I should view one of those controls. One button is also there in that page When i click that button then i should view other one. How to do that.? I got it by changing AutoEv |
Try using
Page.loadControl(virtualpath)
virtualpath=path of the2 nd user control.
then add the user control to the placeholder control that u have declared on the form
something like;
protected void btn1_Click(object sender, EventArgs e) { string files = Path.GetFileName("~/usercontrol2.ascx").ToString(); Control getcontrol = Page.LoadControl(files); PlaceHolder1.Controls.Add(getcontrol); }
Hope it helps!!
|
| |
Back To Question | |