That's not how ASP.NET works - you can't call server-side code from script like that.
ASP.NET receives a request from the client. It executes code - including anything inside a
<% ... %>
or
<%= ... %>
block - and generates a response which is sent to the client. The javascript code then executes on the client.
Your javascript
Receivedata
variable will contain the value of the session variable
when the page was first requested. If a subsequent request changes the session variable, that change will not be visible to your javascript unless you reload the page.
Your "child form" page sets the session variable to the literal string
"' + senddata + '"
when the page loads. It does not know anything about the javascript variable called "senddata".
Also,
showModalDialog
was
removed from Chrome May[
^], and
from Firefox in June[
^]. It's deprecated in IE11, and not supported in Microsoft Edge.
There are various options to replace this deprecated method - for example, these
two[
^]
polyfills[
^].
You would then rewrite your code to use
window.returnValue
in the child form to return the data to the parent form:
var data = window.showModalDialog(sURL, "Lookup", sFeatures1, true);
alert(data);
window.returnValue = data;
window.close();