473,386 Members | 1,766 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,386 software developers and data experts.

web user controls and placeholders

i had created a web user control named "uscItems.ascx"
and a web form named "pkg.aspx"

i added placeholder in "pkg.aspx" then in load_page i wrote this code

dim usc1 as UserControl=LoadControl("uscItems.ascx")
Me.PlaceHolder1.Controls.Add(usc1)

inside my "uscItems.ascx" there r few components:image,label,checkbox
then now i would like to change the label's text, how can i access to my
user control components???

thanks

cyndie

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
1 1080
As long as they are server control's, marked with a runat="server" and a
valid ID then you can access them via usc1.FindControl(s).
You could also set up public properties on usc1 that modify the text. This
is probably the preferred method and will also be a bit faster.
In your uscItems.ascx.cs you would just define
public String LabelCaption
{
get { return MyLabelControl.Text; }
set { MyLabelControl.Text = value; }
}
Then you could just go usc1.LabelCAption = "...."; Just remember that the
control you are modifying has to have a runat="server" tag along with a
valid ID and should also have a variable declaration in your code behind if
the Designer did not automagically put it there already. (switching from
design view to code) and vice versa usually triggers vs.net to automagically
add it.
Some sample C# code but easily adaptable to whatever .NET langauge you are
using.
the

"cyndie woodster via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in
message news:d4******************************@DotNetMonste r.com...
i had created a web user control named "uscItems.ascx"
and a web form named "pkg.aspx"

i added placeholder in "pkg.aspx" then in load_page i wrote this code

dim usc1 as UserControl=LoadControl("uscItems.ascx")
Me.PlaceHolder1.Controls.Add(usc1)

inside my "uscItems.ascx" there r few components:image,label,checkbox
then now i would like to change the label's text, how can i access to my
user control components???

thanks

cyndie

--
Message posted via http://www.dotnetmonster.com

Nov 19 '05 #2

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

Similar topics

4
by: Ron Vecchi | last post by:
In the RenderControl() method I have some code which will catch the controls HTML output. But what I'm tring to accomplish is catching only a perticular control and its child controls. The code...
5
by: Henke | last post by:
Hi! I add some web user controls dynamicly with: myPanel.Controls.Add(Page.LoadControl("MyDynamiclyAddedPage.ascx")); the style of the controls on the user control is set from a css-class, by...
1
by: Dan | last post by:
I have an asp.net page default.aspx with a user control and a placeholder control. <html> <body> <form id="myform" method="post" runat="server" /> <PageHeader:Header id="header1"...
1
by: Josh | last post by:
Hi Guys, I have been having a big problem with trying to pass parameters into a user control when the user control is dynamically loaded into a placholder. I am developing in c#. I have get...
1
by: Vi | last post by:
Hi, I have a User Control that I want to display at the top and bottom of the web form. I have two PlaceHolders controls at the top and bottom of the page and I'm loading the control...
0
by: jonelling | last post by:
I am having a problem where the page load event is not being fired for certain user controls that I load dynamically in placeholders. Here is what I'm doing in brief, with full test code supplied...
14
by: Joe | last post by:
Hello All: I am trying to dynamically populate a web page with literal content and controls (textboxes and checkboxes (and eventually two buttons - the buttons do not appear in the code yet). I...
2
by: Ben Amada | last post by:
Hello, A partner is going to be creating some HTML files that I plan on converting to user controls (UC) and dynamically load at runtime. I'm guessing Visual Studio doesn't come with some...
1
by: =?Utf-8?B?SlA=?= | last post by:
I have a default.aspx page. Default.aspx has placeholders. ASCX user controls are loaded into these placeholders at Page_Load. Each user control has a MultiView, within that there are two views...
0
abehm
by: abehm | last post by:
I have a couple placeholders in which I want to dynamically load user controls into a multi-pageview based on db data. The database returns the filename of the user control (i.e....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.