Ask a Question related to ASP.NET Building Controls, Design and Development.
-
John Carnahan #1
User Control - setting properties
Don't quite get it.
User control has a label in a html table and I want to set the text property
of the label from code behind. (MyLabel)
<%@ Register TagPrefix="MCP" TagName="TOPMENU" src="TopMenu.ascx" %>
<HTML>
FORM....
<MCP:TOPMENU id="TopMenu1" runat="server"></MCP:TOPMENU>
CODE BEHIND...PAGE LOAD
??? MyLabel.Text="Something"
Can't see the label object in the code behind... Why not? How do I get to
it?
John Carnahan Guest
-
Setting web custom control properties at design time
I am developing a Web custom control whose properties (such as text) I would like to map to other control properties (such as textbox1.text) or... -
setting control properties based on another control
I have a grid, a label within the grid, and another grid within the grid. I want the label to be the same size as the child grid, how would I do... -
Setting Control Properties with a Control Builder
I have a control that requires a custom ControlBuilder to parse certain child tags as controls, but I also want to use other tags to set properties.... -
User Control properties
Hi all, I'm a total newbie, so this might be stupid... Anyway, I've created an expanding tree of categories control, based on DataList. It works... -
Setting Properties on a user control on from the Parent Page
"Eric Elliston" <eelliston@neighborhoodamerica.com> wrote in message news:OiPSIL2ZDHA.1492@TK2MSFTNGP12.phx.gbl... All and control end the -
Scott Mitchell [MVP] #2
Re: User Control - setting properties
> User control has a label in a html table and I want to set the text property
John, give the User Control a public string property, like MyLabelText.> of the label from code behind. (MyLabel)
>
> <%@ Register TagPrefix="MCP" TagName="TOPMENU" src="TopMenu.ascx" %>
> <HTML>
>
>
> FORM....
> <MCP:TOPMENU id="TopMenu1" runat="server"></MCP:TOPMENU>
>
>
> CODE BEHIND...PAGE LOAD
>
> ??? MyLabel.Text="Something"
>
> Can't see the label object in the code behind... Why not? How do I get to
> it?
Then in the Page_Load event of the User Control, set its Label's Text
property to the value of the MyLabelText property. In the ASP.NET Web
page's code behind class, set the User Control's MyLabelText like so:
TopMenu1.MyLabelText = "Foo"
(You'll need to have manually added in a reference to TopMenu1 in your
class, like:
Protected TopMenu1 as TopMenu
)
For more information, be sure to read:
An Extensive Examination Of User Controls
[url]http://msdn.microsoft.com/asp.net/using/building/webcontrols/default.aspx?pull=/library/en-us/dnaspp/html/usercontrols.asp[/url]
Happy Programming!
--
Scott Mitchell
[email]mitchell@4guysfromrolla.com[/email]
[url]http://www.4GuysFromRolla.com[/url]
[url]http://www.ASPFAQs.com[/url]
[url]http://www.ASPMessageboard.com[/url]
* When you think ASP, think 4GuysFromRolla.com!
Scott Mitchell [MVP] Guest
-
John Carnahan #3
Re: User Control - setting properties
Works great, thanks
"Scott Mitchell [MVP]" <mitchell@4guysfromrolla.com> wrote in message
news:4096B0C3.3050306@4guysfromrolla.com...property> > User control has a label in a html table and I want to set the textto> > of the label from code behind. (MyLabel)
> >
> > <%@ Register TagPrefix="MCP" TagName="TOPMENU" src="TopMenu.ascx" %>
> > <HTML>
> >
> >
> > FORM....
> > <MCP:TOPMENU id="TopMenu1" runat="server"></MCP:TOPMENU>
> >
> >
> > CODE BEHIND...PAGE LOAD
> >
> > ??? MyLabel.Text="Something"
> >
> > Can't see the label object in the code behind... Why not? How do I get[url]http://msdn.microsoft.com/asp.net/using/building/webcontrols/default.aspx?pu[/url]>> > it?
> John, give the User Control a public string property, like MyLabelText.
> Then in the Page_Load event of the User Control, set its Label's Text
> property to the value of the MyLabelText property. In the ASP.NET Web
> page's code behind class, set the User Control's MyLabelText like so:
>
> TopMenu1.MyLabelText = "Foo"
>
> (You'll need to have manually added in a reference to TopMenu1 in your
> class, like:
>
> Protected TopMenu1 as TopMenu
> )
>
> For more information, be sure to read:
>
> An Extensive Examination Of User Controls
>
ll=/library/en-us/dnaspp/html/usercontrols.asp>
> Happy Programming!
>
> --
>
> Scott Mitchell
> [email]mitchell@4guysfromrolla.com[/email]
> [url]http://www.4GuysFromRolla.com[/url]
> [url]http://www.ASPFAQs.com[/url]
> [url]http://www.ASPMessageboard.com[/url]
>
> * When you think ASP, think 4GuysFromRolla.com!
John Carnahan Guest



Reply With Quote

