You can do this by Ajax.
Add reference of “jquery-1.4.1.min.js” or ”jquery-1.5.1.min.js” in your .aspx page.
In below code Javascript function "JqueryAjaxExample" will call Page Load Of Page2.aspx.
Javascript function "JqueryAjaxExampleResponse" will invoke when response will come back from Page2.aspx.
<script language="javascript" type="text/javascript">
function JqueryAjaxExample() {
$.ajax({
type: "GET",
url: "Page2.aspx",
success: function (ReturnValue) {
JqueryAjaxExampleResponse(ReturnValue);
}
});
}
function JqueryAjaxExampleResponse(ReturnValue) {
alert(ReturnValue);
}
</script>
Then write your return value to Response in your function as below.
protected void Page_Load(object sender, EventArgs e)
{
ReturnValueFunction();
}
private void ReturnValueFunction()
{
string ReturnValue = "SomeThing";
Response.Clear();
Response.Write(ReturnValue);
Response.End();
}