473,396 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Setting UserControls properties at Runtime

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
Nov 17 '05 #1
2 1548
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.

"SamIAm" <sa****@rubbachicken.com> wrote in message
news:eY***************@tk2msftngp13.phx.gbl...
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

Nov 17 '05 #2
I have tried binding at runtime but cannot set any properties as I get cast
exceptions (see code below)??

"Alexander M. Polak" <am******@highpotech.nl> wrote in message
news:bi**********@news.hccnet.nl...
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.

"SamIAm" <sa****@rubbachicken.com> wrote in message
news:eY***************@tk2msftngp13.phx.gbl...
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


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kate | last post by:
Hi: I have a picturebox control, and at runtime various usercontrols are added to it to make a diagram. As dynamically added usercontrols, they are of type VBExtender. Is there a way to save...
2
by: Emma | last post by:
Hi, I'm developing a GUI with almost all Usercontrols. It's been working wonderfull up till a few weeks ago, and really crashed yesterday. Suddenly I can no longer add some of my usercontrols...
1
by: Frank Yamrick | last post by:
I am trying to program an application that requires a large number of screnes that are very similar in the respect that all the bottons and labels interact with each other with the same...
3
by: YYZ | last post by:
I swear I've done my research, and now I was just hoping someone could explain this to me. I've got a base class (usercontrol) that I am using just as an interface. Meaning, I've defined...
1
by: Mian Mahboob | last post by:
Nicholas Paldino in my application a have an Windows form on that i place an Panel Control. in Form load event i ganerate an Form in Panel Control on Runtime then get an design time create...
7
by: Ronald S. Cook | last post by:
In a .NET Windows app, if I set somehting like the title of the form to "MyApp" at run-time, will that make the app run slightly slower than if I had set the title at design-time? Thanks, Ron
2
by: DC | last post by:
Hi, I want to keep all my layout information in the .ascx file of a UserControl. If I require layout related data in codebehind, I would usually use properties defined in the codebehind, e.g. ...
4
by: Nathan Sokalski | last post by:
In several of my UserControls I add properties. If I access these properties in the CodeBehind of the pages that use the controls, I recieve an error when compiling. The reason for this is because...
7
by: Nathan Sokalski | last post by:
I have a page which I dynamically add several usercontrols (*.ascx files) to using the following code: Public Sub Refresh() For Each section As DataRow In Me.GetSections().Rows...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.