Dynamically Set UserControls
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngbeta' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Scott Watermasysk (VIP)
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" />

Reply to this message...
 
    
Christoph Mueller
> Is it possible to set the MyTitle value using a variable instead?
Yes, simply write <Channel:Title id="title1" />. And now you can set the
property in code like: title1.MyTitle=myVar1;

Christoph

Reply to this message...
 
 
System.EventArgs
System.Web.UI.Page




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com