By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,247 Members | 871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,247 IT Pros & Developers. It's quick & easy.

Server variables in ASP.NET Html code

P: n/a
Given i have some control which has an "ImageURL" property. If this property
is set, then the HTML code for the web control looks something like:

<mns:image id=MyImg runat=server ImageURL="images/somepath.jpg"></mns:image>

Given i have some server variable Session("AppRoot") which declares the full
path to the root of the application, for example
Session("AppRoot") = "http://www.someserver.com/myapp/"

Now is there any way i can put the AppRoot variable directly into the HTML
control for the mns:image control, rather than having to put code in the .vb
file to do something like
MyImg.ImageURL = Session("AppRoot") & MyImg.ImageURL

Could i somehow do SOMEthing like:

<mns:image id=MyImg runat=server
ImageURL='<%# Session("AppRoot")%>images/somepath.jpg'>
</mns:image>
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
There are a number of things I don't understand.

1-
If this is your own server control, or you have access to the source, why
not simply put the code ImageUrl = Session("AppRoot") & ImageUrl in the
class before the render? This way you don't have to worry about doing it
either at the page level or the codebehind. If you don't write your own
that inherits from this one.

2-
Does the AppRoot actually belong to the sesssion? it's specific to each
user?

3-
You can simply use ~ to denote the application root, ala:
ImageUrl="~/images/somepath.jpg"

4-
The answer to your question is no..but the solution in #1 will solve her
right up.

Karl

"A Traveler" <hi*********************@yahoo.com> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...
Given i have some control which has an "ImageURL" property. If this property is set, then the HTML code for the web control looks something like:

<mns:image id=MyImg runat=server ImageURL="images/somepath.jpg"></mns:image>
Given i have some server variable Session("AppRoot") which declares the full path to the root of the application, for example
Session("AppRoot") = "http://www.someserver.com/myapp/"

Now is there any way i can put the AppRoot variable directly into the HTML
control for the mns:image control, rather than having to put code in the ..vb file to do something like
MyImg.ImageURL = Session("AppRoot") & MyImg.ImageURL

Could i somehow do SOMEthing like:

<mns:image id=MyImg runat=server
ImageURL='<%# Session("AppRoot")%>images/somepath.jpg'>
</mns:image>

Nov 18 '05 #2

P: n/a
Well, i cannot code it into the code for the control, because the control is
made in a separate library meant ot be generic to NO app in specific.

I cannot use a Root path ("/" or "~") because the app does not root at the
root of the site.
The site's root is www.myserver.com/myapp, not www.myserver.com

Otherwise then i guess im just stuck having to alter the urls in the .vb
file then. Thats a little annoying. Itd be nice if you could somehow use
something like the databinding stuff to put out a server variable into
ASP.NET html code.

"Karl" <none> wrote in message news:e$**************@tk2msftngp13.phx.gbl...
There are a number of things I don't understand.

1-
If this is your own server control, or you have access to the source, why
not simply put the code ImageUrl = Session("AppRoot") & ImageUrl in the
class before the render? This way you don't have to worry about doing it
either at the page level or the codebehind. If you don't write your own
that inherits from this one.

2-
Does the AppRoot actually belong to the sesssion? it's specific to each
user?

3-
You can simply use ~ to denote the application root, ala:
ImageUrl="~/images/somepath.jpg"

4-
The answer to your question is no..but the solution in #1 will solve her
right up.

Karl

"A Traveler" <hi*********************@yahoo.com> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...
Given i have some control which has an "ImageURL" property. If this

property
is set, then the HTML code for the web control looks something like:

<mns:image id=MyImg runat=server

ImageURL="images/somepath.jpg"></mns:image>

Given i have some server variable Session("AppRoot") which declares the

full
path to the root of the application, for example
Session("AppRoot") = "http://www.someserver.com/myapp/"

Now is there any way i can put the AppRoot variable directly into the HTML control for the mns:image control, rather than having to put code in the

.vb
file to do something like
MyImg.ImageURL = Session("AppRoot") & MyImg.ImageURL

Could i somehow do SOMEthing like:

<mns:image id=MyImg runat=server
ImageURL='<%# Session("AppRoot")%>images/somepath.jpg'>
</mns:image>


Nov 18 '05 #3

P: n/a
~ uses the virtual app..so it should be ~ should be equal to /myapp

and you could still make the code generic to no specific app (as it is now
actually, it's specific to apps at the root level so it isn't very
generic)...but ~ should do the trick.

Karl

"A Traveler" <hi*********************@yahoo.com> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
Well, i cannot code it into the code for the control, because the control is made in a separate library meant ot be generic to NO app in specific.

I cannot use a Root path ("/" or "~") because the app does not root at the
root of the site.
The site's root is www.myserver.com/myapp, not www.myserver.com

Otherwise then i guess im just stuck having to alter the urls in the .vb
file then. Thats a little annoying. Itd be nice if you could somehow use
something like the databinding stuff to put out a server variable into
ASP.NET html code.

"Karl" <none> wrote in message

news:e$**************@tk2msftngp13.phx.gbl...
There are a number of things I don't understand.

1-
If this is your own server control, or you have access to the source, why
not simply put the code ImageUrl = Session("AppRoot") & ImageUrl in the
class before the render? This way you don't have to worry about doing it
either at the page level or the codebehind. If you don't write your own that inherits from this one.

2-
Does the AppRoot actually belong to the sesssion? it's specific to each
user?

3-
You can simply use ~ to denote the application root, ala:
ImageUrl="~/images/somepath.jpg"

4-
The answer to your question is no..but the solution in #1 will solve her
right up.

Karl

"A Traveler" <hi*********************@yahoo.com> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...
Given i have some control which has an "ImageURL" property. If this

property
is set, then the HTML code for the web control looks something like:

<mns:image id=MyImg runat=server

ImageURL="images/somepath.jpg"></mns:image>

Given i have some server variable Session("AppRoot") which declares
the full
path to the root of the application, for example
Session("AppRoot") = "http://www.someserver.com/myapp/"

Now is there any way i can put the AppRoot variable directly into the HTML control for the mns:image control, rather than having to put code in

the .vb
file to do something like
MyImg.ImageURL = Session("AppRoot") & MyImg.ImageURL

Could i somehow do SOMEthing like:

<mns:image id=MyImg runat=server
ImageURL='<%# Session("AppRoot")%>images/somepath.jpg'>
</mns:image>



Nov 18 '05 #4

P: n/a
Hmm, .. well, i tried using the ~ instead and taking out my code in .vb to
prepend the approot to the path, but it does not work with the ~.

Thanks though for the idea.
"Karl" <none> wrote in message news:OK**************@TK2MSFTNGP10.phx.gbl...
~ uses the virtual app..so it should be ~ should be equal to /myapp

and you could still make the code generic to no specific app (as it is now
actually, it's specific to apps at the root level so it isn't very
generic)...but ~ should do the trick.

Karl

"A Traveler" <hi*********************@yahoo.com> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
Well, i cannot code it into the code for the control, because the control
is
made in a separate library meant ot be generic to NO app in specific.

I cannot use a Root path ("/" or "~") because the app does not root at the root of the site.
The site's root is www.myserver.com/myapp, not www.myserver.com

Otherwise then i guess im just stuck having to alter the urls in the .vb
file then. Thats a little annoying. Itd be nice if you could somehow use
something like the databinding stuff to put out a server variable into
ASP.NET html code.

"Karl" <none> wrote in message

news:e$**************@tk2msftngp13.phx.gbl... There are a number of things I don't understand.

1-
If this is your own server control, or you have access to the source, why not simply put the code ImageUrl = Session("AppRoot") & ImageUrl in the class before the render? This way you don't have to worry about doing it either at the page level or the codebehind. If you don't write your own that inherits from this one.

2-
Does the AppRoot actually belong to the sesssion? it's specific to each user?

3-
You can simply use ~ to denote the application root, ala:
ImageUrl="~/images/somepath.jpg"

4-
The answer to your question is no..but the solution in #1 will solve her right up.

Karl

"A Traveler" <hi*********************@yahoo.com> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...
> Given i have some control which has an "ImageURL" property. If this
property
> is set, then the HTML code for the web control looks something like:
>
> <mns:image id=MyImg runat=server
ImageURL="images/somepath.jpg"></mns:image>
>
> Given i have some server variable Session("AppRoot") which declares the full
> path to the root of the application, for example
> Session("AppRoot") = "http://www.someserver.com/myapp/"
>
> Now is there any way i can put the AppRoot variable directly into
the
HTML
> control for the mns:image control, rather than having to put code in

the .vb
> file to do something like
> MyImg.ImageURL = Session("AppRoot") & MyImg.ImageURL
>
> Could i somehow do SOMEthing like:
>
> <mns:image id=MyImg runat=server
> ImageURL='<%# Session("AppRoot")%>images/somepath.jpg'>
> </mns:image>
>
>



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.