Re: Accessing a code behind variable from ASPX

From: Ben Strackany (infoNOSPAM_at_developmentnow.nospam.com)
Date: 11/24/04


Date: Wed, 24 Nov 2004 17:23:53 -0600

Can you make that public variable a property of the user control, assign the
user control an id, & then access it with <usercontrolid>.<propertyname> ?

-- 
Ben Strackany
www.developmentnow.com
<a href="http://www.developmentnow.com">dn</a>
"Ryan Taylor" <rtaylor@stgeorgeconsulting.com> wrote in message
news:O3Qt%23Ij0EHA.424@TK2MSFTNGP14.phx.gbl...
> Hi.
>
> I need to be able to access a public code behind variable within my ASPX
> page. The reason is that I have a user control "Header" which defines a
> table layout, and is included in all my pages, at various levels in the
> website heirarchy. The table requires a background image. My images
folders
> is at the root of the website, effectively "~/images/". I need the
> background image to show whether I at a page in the root of my website or
in
> some other directory a few folders down. Normally, I could just write
> "~/images/image.jpg" if I was in a code behind file, but I cannot use this
> syntax in the ASPX page. So, I have a "VirtualRoot" public variable
declared
> in my Header.cs file, and this variable is assigned
Request.ApplicationPath
> on the Page_Load event. This will give me the appropropriate path to
prefix
> /images/image.jpg. But I cannot remember how to access this variable from
> the ASPX page. Any ideas?
>
> Thanks in advance.
> Ryan
>
>


Relevant Pages

  • Accessing a code behind variable from ASPX
    ... I need to be able to access a public code behind variable within my ASPX ... The table requires a background image. ... is at the root of the website, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: User Control Code-Behind
    ... I have an ASPX page named MyPage.aspx. ... encapsulated in a code-behind named MyPage.aspx.vb. ... The ASPX page also uses a user control named MyUC.ascx.The user control ... Sub Page_Load ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Context is not a member of....
    ... In the code behind of the ASPX page that uses the user control? ... Enter.ascx.vb resides in the App_Code directory, if I add the CodeFile ... TextBoxes are named txt1 & txt2. ...
    (microsoft.public.dotnet.framework.aspnet)
  • User Control Code-Behind
    ... Assume that a user control encapsulates 2 TextBoxes with ... Assuming that the ASPX page doesn't use a code-behind, ... Sub Page_Load ... Now I decide to use a code-behind for the ASPX ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Context is not a member of....
    ... The reason you need to use References vs Imports is: in 2.0 each aspx and codefile is compiled into it's OWN assembly - who's name is dynamically created, ... and make the user control's type available to the page...You can use Reference on a user control and point it to the page to do the opposite, but this has the side effect of locking your user control to that page - which isn't very good. ...
    (microsoft.public.dotnet.framework.aspnet)