tags:

views:

420

answers:

1

Hi,

I have a page where I am getting session values then calling form action through javaScript, please see the code below

<%@ Page language="c#" AutoEventWireup="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
<html>
  <head>
    <title>SessionRedirect</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name=vs_defaultClientScript content="JavaScript">
    <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5"&gt;
  </head>
  <body MS_POSITIONING="GridLayout">    
    <form method="post" name="frmRedirect" target="_blank">   
     <input type="hidden" name="email" value="<%=Session["Email"].ToString() %>" />
     <input type="hidden" name="pass" value="<%= Session["PWD"].ToString() %>" />
     <input type="hidden" name="User" value="<%= Session["User"].ToString() %>" />
     </form>
<script type="text/javascript"> 
    if(frmRedirect.User.value == "P")
        {    
     frmRedirect.action = "http://cmsstag/partnerzone/index.aspx";  
      }
    else
     frmRedirect.action = "http://cmsstag/studentportal/index.aspx";

    document.frmRedirect.submit(); 
    location.replace("index.aspx");

</script>
<%
      Session.Remove("registration");
            Session.Remove("User");
            Session.Remove("UserId");
            Session.Remove("UserLoggedIn");
            Session.Remove("AgentCode");
      Session.Abandon();
%>  
  </body>
</html>

Now I want to open page in new window with size given by me when I use "frmRedirect.action" used in above code.

A: 

This is a rather complicated example. What you could try is:

  1. open a new window first with javascript window.open() and set its dimensions and name
  2. submit the form to it setting the correct target name as you've set it in window.open()

I've tried it. It works.

Edit
This is the code for you. Maybe you will have to set some time between opening a new window and submitting a form to make sure the window is already created (use setTimeout).

// open a new window with proper size    
window.open("", "MySubWindow", "height=480,width=640");

// do your action assignments

frmRedirect.target = "MySubWindow";
frmRedirect.submit();
location.replace("index.aspx");
Robert Koritnik
thanks, can you please give me code using my above code?
MKS
Robert can you please give some code for what you are trying to say!
MKS
Thanks Robert, I have tested your code on machine, the problem now is that it is loosing the session values which I need on the opening page, please see the code above
MKS
Well you've removed all your session variables in the first page load, haven't you? No wonder there aren't any. Server-side code gets executed before the page is sent to the client. In your code example you 1) fill-in input form field, 2) remove Session variables and 3) return page to the client where form submission happens.
Robert Koritnik
Sorry Robert, I am not able to understand your above comment can you please give me some example for it
MKS
Thanks Robert, I managed to do that, again thanks for your great help!
MKS
any up vote for my answer?
Robert Koritnik