|
 |
aspx thread: Dynamically Set UserControls
Message #1 by Scott Watermasysk <swatermasysk@C...> on Sun, 13 May 2001 10:48:21 -0400
|
|
I found this example on http://www.123aspx.com.
(http://www.123aspx.com/resdetail.asp?rid=937)
Is it possible to set the MyTitle value using a variable instead?
i.e., could I set it equal to a variable called ABC and not "ABC"
litterally?
-Scott
in myuc.aspx
-------------------------------
<%-- declare any namespaces --%>
<%@ Register Tagprefix="Channel" Tagname="Title" src="myuc.ascx"%>
<Channel:Title MyTitle="ABC" />
In myuc.ascx
-------------------------------
<script language="C#" runat="server">
public String MyTitle ="Not Set";
void Page_Load(Object Sender, EventArgs e)
{
if (Page.IsPostBack == false)
{
DisplayTitle.Text = MyTitle.ToString();
}
}
</Script>
<asp:Label id="DisplayTitle" runat="server" />
Message #2 by "Richard Anderson" <rja@a...> on Tue, 22 May 2001 21:19:55 +0100
|
|
Set it in the page load event for your page, eg:
<Channel:Title id="somecontrol" runat=server/>
protected void Page_Load( object sender, EventArgs e )
{
somecontrol.MyTitle = somevariable;
}
or just use the regular ASP way:
<Channel:Title MyTitle="<%=SomeVariable%>" />
hth,
Rich.
----- Original Message -----
From: "Scott Watermasysk" <swatermasysk@C...>
To: "ASP+" <aspx@p...>
Sent: Sunday, May 13, 2001 3:48 PM
Subject: [aspx] Dynamically Set UserControls
> I found this example on http://www.123aspx.com.
> (http://www.123aspx.com/resdetail.asp?rid=937)
>
> Is it possible to set the MyTitle value using a variable instead?
>
> i.e., could I set it equal to a variable called ABC and not "ABC"
> litterally?
>
> -Scott
>
> in myuc.aspx
> -------------------------------
> <%-- declare any namespaces --%>
> <%@ Register Tagprefix="Channel" Tagname="Title" src="myuc.ascx"%>
> <Channel:Title MyTitle="ABC" />
>
> In myuc.ascx
> -------------------------------
> <script language="C#" runat="server">
> public String MyTitle ="Not Set";
> void Page_Load(Object Sender, EventArgs e)
> {
> if (Page.IsPostBack == false)
> {
> DisplayTitle.Text = MyTitle.ToString();
> }
> }
> </Script>
> <asp:Label id="DisplayTitle" runat="server" />
>
>
|
|
 |