I already know how to exposing a public variable, but I was thinking doing
it all in the user control was better. However, I'm now thinking exposing
the public variable is the way to go. what do you think?
Example:
*Header.ascx - user control
Public Greeting As String
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
lblGreeting.Text = Greeting
End Sub
-----------------------------------------------------------------------------------------------------------------------------------------------------
*Home.aspx.vb - code behind class
Public ctlHeader As Header
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.ctlHeader.Greeting = "Welcome To MySite.Com"
End Sub
"Anders Borum" <an****@sphereworks.dk> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...
You could develop a UserControl that exposed a public property such as
GreetingText. When embedding the UserControl on the different physical
aspx
pages, you could simply set the getting text by assigning it to the
attribute of the server side control tag.
<CustomerName:GreetingDisplay id="ctrl" runat="server"
GreetingText="Here's
ny custom greeting text" />
This is the simple version. You could change the parsing of child controls
for the UserControl, allowing for more customization - e.g. by allowing
HTML
content within the opening and closing tags of the server side control
tag.
<CustomerName:GreetingDisplay id="ctrl" runat="server">
<div>
<b>Welcome!</b> <br />
<div>Some other text ..</div>
</div>
</CustomerName:GreetingDisplay>
Look for the "ParseChildren" .NET attribute on your UserControl class. The
.NET documentation talks about this attribute and explains how you get
access to the embedded markup within the control tags.
If this doesn't help, please let me know :-)
--
venlig hilsen / with regards
anders borum
--