Pass Variable Value To User Control From Host Page

lmo10

Member
Joined
Mar 29, 2005
Messages
8
Programming Experience
1-3
I am trying to pass the value of a varible to a user control (code behind) from the host page of the user control. In the uc code behind I am using Get...Set to retrive the value and if I use a static string (i.e "blk") it works but I cannot get it to work using (<%#variable%>. Here is the code:

In the user control code behind
VB.NET:
		Public mainSkin As String

		Public Property ucSkin() As String
			Get
				Return ucSkin
			End Get
			Set(ByVal value As String)
				mainSkin = value
			End Set
		End Property

Here is the code from the host page
VB.NET:
<jsFlsAd:flsAd  id="FlsAd" runat="server" ucSkin= "<%#varSkin%>"></jsFlsAd:flsAd>
Where varSkin is declared as Public in the code behind of the host page.

The above line does not work, however if I change it to:
VB.NET:
<jsFlsAd:flsAd  id="FlsAd" runat="server" ucSkin= "blk"></jsFlsAd:flsAd>
That will work.
Can someone help me understand what I am doing wrong?
 
Well as I stated in my post above yours, im a newb but what I discovered after hours of troubleshooting was when trying to dynamically assign a regular expression to a control would not work at all..

I tried
<asp:RegularExpressionValidator id="RegExptxt" ValidationExpression=myexp
<asp:RegularExpressionValidator id="RegExptxt" ValidationExpression=<%=myexp%>

RegExptxt.ValidationExpression = "<%=myexp%>"
RegExptxt.ValidationExpression = <%=myexp%>
RegExptxt.ValidationExpression = myexp

nothing worked..
turns out the problem was that for some reason these values dont get added until AFTER the page loads so putting RegExptxt.ValidationExpression = myexp works when in the Page_Load Event..

maybe this will help you..
 
Back
Top