Results 1 to 3 of 3

Thread: Pass Variable Value To User Control From Host Page

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    40

    Exclamation Pass Variable Value To User Control From Host Page

    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
    Code:
            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
    Code:
    <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:
    Code:
    <jsFlsAd:flsAd  id="FlsAd" runat="server" ucSkin= "blk"></jsFlsAd:flsAd>
    That will work.
    Can someone help me understand what I am doing wrong?

  2. #2
    Fanatic Member -TPM-'s Avatar
    Join Date
    Jul 2005
    Posts
    850

    Re: Pass Variable Value To User Control From Host Page

    Hmm try taking out the " around <%#varskin%>
    ie:
    Code:
    <jsFlsAd:flsAd  id="FlsAd" runat="server" ucSkin= <%#varSkin%> ></jsFlsAd:flsAd>
    TPM

    Add yourself to the VBForums Frappr Map!!

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    40

    Re: Pass Variable Value To User Control From Host Page

    Quote Originally Posted by -TPM-
    Hmm try taking out the " around <%#varskin%>
    ie:
    Code:
    <jsFlsAd:flsAd  id="FlsAd" runat="server" ucSkin= <%#varSkin%> ></jsFlsAd:flsAd>
    I tried that and it didnt work either. The way I got it solved for all who comes across this:

    In the Page_Init sub I used

    FlsAd.ucSkin = varSkin

    Where
    FlsAd = The id of the User Control
    ucSkin is the custom property
    varSkin is the variable that holds the value that I wanted to pass.

    All is fine. Thanks for the reply

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width