Saturday, March 24, 2012

Pass Variable To User Control

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" />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!
<rhungund@.gmail.com> wrote in message
news:1134604813.689597.220380@.g43g2000cwa.googlegroups.com...
> 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" />
>
great. that worked! thank you.

0 comments:

Post a Comment