Reputation: 1
Wonder if anyone can help as im really stuck on a problem i'm having
Using vb.net I have a web application with several .aspx pages.
on one of my aspx pages I have a javascript function that i want to retrieve a pdf path from a session value i set within code behind. After searching the web everywhere seems to say use something like the following
var pdf_link = '<%=Session["pdfpath"].ToString() %>';
here is the javascript function:
function showmodal() {
var pdf_link = '<%=Session["pdfpath"].ToString() %>';
var iframe = '<div class="iframe-container"><iframe src="' + pdf_link + '"></iframe></div>'
$.createModal({
title: 'PDF Preview',
message: iframe,
closeButton: true,
scrollable: false
});
}
to get the value but i get an error message before i can even compile 'Identifier Expected' and it highlights between the [" as being the problem area. i just can't get this to work what am i doing wrong.
Also because i couldn't workout what was wrong with the above i have tried saving the value i want into a hidden field and tried to access that using the following
document.getElementById("PdfPathHiddenField").value
but that just returns null all the time. I just can't seem to access anything within my javascript function.
What i also see as odd is for instance when debugging i have say page1.aspx and page2.aspx. From page1.aspx in code behind on a button click i use
Response.Redirect("~/page2.aspx")
When I have stopped the debugger within my javascript function on page2.aspx to retrieve the value i notice that the tab with the code where the debugger has stopped for page2.aspx is titled page1[Dynamic] but it is the correct source from page2.aspx not page1.aspx really confused as shouldn't it say page2[Dynamic] on that - is this why i maybe can't seem to access any controls as it thinks it's elsewhere ???? Help
Thanks in advance any help would be much appreciated.
Upvotes: 0
Views: 482
Reputation: 2773
In VB.NET arrays have parentessis, Session("pdfpath").ToString()
, in C# or javascript you can use square brackets, but not in VB.
PS: Remeber to mark this an answer if it's a solution for your problem
Upvotes: 0