Change user controls in runtime using c#
-
Hello, I have a default page on which there are three user controls put inside three panels within the page. Based on a click event of a button in any of the user control, i want to unload a user control in the page and load a diferent user control in its place. I am using VS 2008 and C# as the code behind... Your inputs would be very helpful....Thanks in advance
-
Hello, I have a default page on which there are three user controls put inside three panels within the page. Based on a click event of a button in any of the user control, i want to unload a user control in the page and load a diferent user control in its place. I am using VS 2008 and C# as the code behind... Your inputs would be very helpful....Thanks in advance
I believe this is a ASP.Net Question , So please post it on asp.net forum.
cheers, Abhijit CodeProject.Com MVP
-
Hello, I have a default page on which there are three user controls put inside three panels within the page. Based on a click event of a button in any of the user control, i want to unload a user control in the page and load a diferent user control in its place. I am using VS 2008 and C# as the code behind... Your inputs would be very helpful....Thanks in advance
You could make the Set the
Visible
property on the controls to the appropriate value so they are not rendered to the client unless they need to be.* Developer Day Scotland 2 - Free community conference * The Blog of Colin Angus Mackay
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
-
I believe this is a ASP.Net Question , So please post it on asp.net forum.
cheers, Abhijit CodeProject.Com MVP
You can do it using delegates. Create a delegate in the usercontrol with some return type / parameters with which you can set the visibility of the usercontrol, add an event for this delegate. Add a button with a button click event in user ctrl. Call the event in the webpage which in turn should call the user control's button click event. Try this out. Cheers, Sudhanva
-
Hello, I have a default page on which there are three user controls put inside three panels within the page. Based on a click event of a button in any of the user control, i want to unload a user control in the page and load a diferent user control in its place. I am using VS 2008 and C# as the code behind... Your inputs would be very helpful....Thanks in advance
I would personally instantiate all of them with the
Visible
property set to false, and then show/hide them as necessary. You can even initialize them when heVisibleChanged
event is fired."Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
I would personally instantiate all of them with the
Visible
property set to false, and then show/hide them as necessary. You can even initialize them when heVisibleChanged
event is fired."Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001Thank you for the response. But here i am having around 50-60 controls now and the number is again going to increase. Do you think its a good idea to load as many number of controls on the form and keep its visible property false? The requirement is something as that of how Microsoft Dynamics work. We have one default page with left and main content panels that holds the user-controls which keep changing as per the button clicked...