Monday, March 26, 2012

pass value of a variable to user control

Hi,

Trying to pass a value to user control within a page.
1. Couldnt find a way to pass it from code behind file.
2. Trying to pass it from aspx page... using EditURL='<%
"mypage.aspx?myvar=" + myvalue %>' assigns value of EditURL=''
I have tried using a local variable... directly trying to read it off
Request object and even tried using session variable...

could be glad if someone could tell me how to get it right... thanks,

regards,

Hermit DaveYou need to use properties and pass them in the page load events for
example....

Doug Stevens, another MVP has this very useful example whih explains the
approach

http://www.dotnetjunkies.com/Articl...866F720AB013.dc
ik

--
Regards

John Timney (Microsoft ASP.NET MVP)
--------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
--------------

"Hermit Dave" <hermitd.REMOVE@.CAPS.AND.DOTS.hotmail.com> wrote in message
news:uV5MEnQwDHA.556@.TK2MSFTNGP11.phx.gbl...
> Hi,
> Trying to pass a value to user control within a page.
> 1. Couldnt find a way to pass it from code behind file.
> 2. Trying to pass it from aspx page... using EditURL='<%
> "mypage.aspx?myvar=" + myvalue %>' assigns value of EditURL=''
> I have tried using a local variable... directly trying to read it off
> Request object and even tried using session variable...
> could be glad if someone could tell me how to get it right... thanks,
> regards,
> Hermit Dave
Hello John,

Thanks for the pointer. That article hopefully did show me what i wasnt
doing...
For same reason i did look around for the instance of user control in the
data member declaration earlier and couldnt find it...
Anyho... have to map the instance on aspx page to the code behind.. then i
should be able to populate the properties.. (ealier was passing hard coded
values from within aspx and that worked)
Thanks mate,

Regards,

Hermit Dave

"John Timney (Microsoft MVP)" <timneyj@.despammed.com> wrote in message
news:Od4uotQwDHA.3496@.TK2MSFTNGP11.phx.gbl...
> You need to use properties and pass them in the page load events for
> example....
> Doug Stevens, another MVP has this very useful example whih explains the
> approach
>
http://www.dotnetjunkies.com/Articl...866F720AB013.dc
> ik
>
> --
> Regards
> John Timney (Microsoft ASP.NET MVP)
> --------------
> <shameless_author_plug>
> Professional .NET for Java Developers with C#
> ISBN:1-861007-91-4
> Professional Windows Forms
> ISBN: 1861005547
> Professional JSP 2nd Edition
> ISBN: 1861004958
> Professional JSP
> ISBN: 1861003625
> Beginning JSP Web Development
> ISBN: 1861002092
> </shameless_author_plug>
> --------------
> "Hermit Dave" <hermitd.REMOVE@.CAPS.AND.DOTS.hotmail.com> wrote in message
> news:uV5MEnQwDHA.556@.TK2MSFTNGP11.phx.gbl...
> > Hi,
> > Trying to pass a value to user control within a page.
> > 1. Couldnt find a way to pass it from code behind file.
> > 2. Trying to pass it from aspx page... using EditURL='<%
> > "mypage.aspx?myvar=" + myvalue %>' assigns value of EditURL=''
> > I have tried using a local variable... directly trying to read it off
> > Request object and even tried using session variable...
> > could be glad if someone could tell me how to get it right... thanks,
> > regards,
> > Hermit Dave
"Hermit Dave" <hermitd.REMOVE@.CAPS.AND.DOTS.hotmail.com> wrote in message
news:uV5MEnQwDHA.556@.TK2MSFTNGP11.phx.gbl...
> Hi,
> Trying to pass a value to user control within a page.
> 1. Couldnt find a way to pass it from code behind file.
> 2. Trying to pass it from aspx page... using EditURL='<%
> "mypage.aspx?myvar=" + myvalue %>' assigns value of EditURL=''
> I have tried using a local variable... directly trying to read it off
> Request object and even tried using session variable...
> could be glad if someone could tell me how to get it right... thanks,
> regards,
> Hermit Dave

I know you have already been pointed to the Properites as fits your
question.

Just as a side note though, you can also use a Cache object for passing
information to an from controls and web user controls. They are very handy.

--
Rocky Moore
www.HintsAndTips.com

0 comments:

Post a Comment