Setting UserControls properties at Runtime

S

SamIAm

I have a UserControl called "MyControl" The content it delivers is varied my
a parameter: "LanguageID"

<uc1:MyControl id="MainNavigationControl" runat="server" LanguageID="<% What
do I do here%>"></uc1:MyControl >

How do I set the property at run time. I have tried loading the control
using the LoadControl function but get errors when I do a cast to set the
LanguageID property i.e.
Control nav = LoadControl("MyControl.ascx");
((MyControl)nav).LanguageID = "en-US";
somePlaceHolder.Controls.Add(nav);

Any ideas or pointer to resources?

S
 
A

Alexander M. Polak

Do'nt bind the user control at designtime like you dit in HTML, but do it
all at runtime is problably the most simple solution.
 
S

SamIAm

I have tried binding at runtime but cannot set any properties as I get cast
exceptions (see code below)??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top