Solved

get asp.net session variable in HTML

Posted on 2011-03-23
12
481 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

930 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

10 Experts available now in Live!

Get 1:1 Help Now