Solved

get asp.net session variable in HTML

Posted on 2011-03-23
12
478 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
 

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now