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..

Showing Answers 1 - 4 of 4 Answers

rahul

  • Aug 26th, 2006
 

If not mistaken i guss u should put 2 countrols in the page load and one in the form load.If my answer is wrong forgive me.

Rahul

  Was this answer useful?  Yes

whirlpool

  • Dec 20th, 2007
 

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!!

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions