Pass Variable To User Control

Discussion in 'ASP .Net' started by rhungund@gmail.com, Dec 15, 2005.

  1. Guest

    Hi all. I have a user control I'm using as my "include" file for my
    flash navigation. My asp.net app is written in vb.net. The swf file
    takes a parameter which I would like to pass into my user control.
    Ideally i'd like to do something like this:

    <object type="application/x-shockwave-flash"
    data="flash/navigation.swf?page=<%pageName%>" width="850" height="148">
    <param name="movie" value="flash/navigation.swf?page=<%pageName%>" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#000000" />
    </object>

    So how, in all my other pages I'd like to call it like this:

    <myControl:incNavigation runat="server" ID="theNavigation"
    pageName="home" />
     
    , Dec 15, 2005
    #1
    1. Advertising

  2. Karl Seguin Guest

    if you make PageName a property of the user control, this is pretty easy.

    private _pageName as string

    public property PageName as String
    get
    return _pageName
    end get
    set (value as string)
    _pageName = value
    end set
    end property

    public sub void Page_Load(...)
    ...
    end sub

    you can then do, as you want

    <myControl:incNavigation runat="server" ID="theNavigation" PageName="home"
    />

    and use PageName in your object, but make sure to use <%= PageName %> (you
    were missing the = in your example)

    Karl


    --
    MY ASP.Net tutorials
    http://www.openmymind.net/
    http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!



    <> wrote in message
    news:...
    > Hi all. I have a user control I'm using as my "include" file for my
    > flash navigation. My asp.net app is written in vb.net. The swf file
    > takes a parameter which I would like to pass into my user control.
    > Ideally i'd like to do something like this:
    >
    > <object type="application/x-shockwave-flash"
    > data="flash/navigation.swf?page=<%pageName%>" width="850" height="148">
    > <param name="movie" value="flash/navigation.swf?page=<%pageName%>" />
    > <param name="quality" value="high" />
    > <param name="bgcolor" value="#000000" />
    > </object>
    >
    > So how, in all my other pages I'd like to call it like this:
    >
    > <myControl:incNavigation runat="server" ID="theNavigation"
    > pageName="home" />
    >
     
    Karl Seguin, Dec 15, 2005
    #2
    1. Advertising

  3. Guest

    great. that worked! thank you.
     
    , Dec 15, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hermit Dave

    pass value of a variable to user control

    Hermit Dave, Dec 12, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    5,595
    Rocky Moore
    Dec 13, 2003
  2. Phil Certain
    Replies:
    12
    Views:
    842
    Phil Certain
    Feb 1, 2005
  3. Tricky
    Replies:
    0
    Views:
    580
    Tricky
    Mar 19, 2009
  4. Tricky
    Replies:
    0
    Views:
    1,007
    Tricky
    Mar 19, 2009
  5. Reuven
    Replies:
    0
    Views:
    596
    Reuven
    Mar 19, 2009
Loading...

Share This Page