Solved

get asp.net session variable in HTML

Posted on 2011-03-23
12
486 Views
Last Modified: 2012-05-11
I am trying to do:

<asp:HyperLink ID="hlMainImageView2"
                                             runat="server" ImageUrl=Session.BaseUrl &  UploadedImages/">View</asp:HyperLink>

Where session is my attempt to get the value of the session BaseUrl as use it has part of the hyperlink
0
Comment
Question by:vbnetcoder
  • 6
  • 6
12 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35201983
try:
<asp:HyperLink ID="hlMainImageView2"
                                             runat="server" ImageUrl=<%Session.BaseUrl%>UploadedImages/">View</asp:HyperLink>

0
 

Author Comment

by:vbnetcoder
ID: 35202382
It gives me this error:

If this attribute value is enclosed in quotation marks, the quotation marks must match.
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35202391
missing a starting quote for the ImageURL attribute:

<asp:HyperLink ID="hlMainImageView2"
                                             runat="server" ImageUrl="<%Session.BaseUrl%>UploadedImages/">View</asp:HyperLink>

0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:vbnetcoder
ID: 35202510
I did this

<br />
<asp:HyperLink ID="HyperLink4"
                                             runat="server" navigateurl="<%Session.BaseUrl%>UploadedImages/100-Main.jpg">View</asp:HyperLink>

AND IT navigated to

http://localhost:52803/MyAPP/products/%3C%Session.BaseUrl%%3EUploadedImages/100-Main.jpg

It did not give me the value for BaseUrL

also /products should not be int the path



0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35202584
ok try this :

<asp:HyperLink ID="HyperLink4"
                                             runat="server" navigateurl="~/<%=Session.BaseUrl%> UploadedImages/100-Main.jpg">View</asp:HyperLink>

note <% has change to <%=

0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35202596
sorry i got that wrong , try :

<asp:HyperLink ID="HyperLink4"
                                             runat="server" navigateurl="<%=Session.BaseUrl%> UploadedImages/100-Main.jpg">View</asp:HyperLink>

0
 

Author Comment

by:vbnetcoder
ID: 35202604
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35202621
ok what about :
<asp:HyperLink ID="HyperLink4"
                                             runat="server" navigateurl=<%=Session.BaseUrl%> & UploadedImages/100-Main.jpg>View</asp:HyperLink>

0
 

Author Comment

by:vbnetcoder
ID: 35202632
IT does not render. IT tells me that the server tag is not well formed
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
ID: 35202650
Actually how about you do this instead :

<asp:HyperLink ID="HyperLink4"
                                             runat="server" navigateurl="~/UploadedImages/100-Main.jpg">View</asp:HyperLink>

0
 

Author Comment

by:vbnetcoder
ID: 35202664
That worked!

Thank you
0
 

Author Closing Comment

by:vbnetcoder
ID: 35202676
ty
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question