?
Solved

get asp.net session variable in HTML

Posted on 2011-03-23
12
Medium Priority
?
501 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

840 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