Click here to Skip to main content
15,504,830 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, iam using asp.net3.5 with c#,
in my site when i clicks on the button it will open child window of another site but i want to pass the user name and password so that i can directly goes to the link.

below is my code for opening the child window, can any body help me to pass the user name and password directly so that the link is open directly.

string url = "";
       string fullURL = "'" + url + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,titlebar=no' );";
       ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);
developerit 30-Jun-12 8:50am    
this.Page.ClientScript.RegisterStartupScript(GetType(), "dd1", "<script language="'javascript'">window.opener.location.href=http://localhost:9880/testProject/Home.aspx?username='"+UserName+"'&Pass='"+Pass+"'; self.close();</script>");

1 solution

You can do it by many ways:
1) Javascript Querystring:
On click of a button in child window just use this:
this.Page.ClientScript.RegisterStartupScript(GetType(), "dd1", "<script language='javascript'>window.opener.location.href=http://localhost:9880/testProject/Home.aspx?username='"+UserName+"'&Pass='"+Pass+"'; self.close();</script>");

But this will not be a good practice.
If you really want to send the username and password then send it through session.
Follow the link for using session variable:
Manage ASP.NET Session Variables using the Facade Design Pattern[^][^]

All the best.
Share this answer
developerit 25-Jun-12 8:02am    
hi i have used the above code
but still it is giving error can you correct me

string username = "abc";
string pwd = "123";
this.Page.ClientScript.RegisterStartupScript(GetType(), "dd1", "<script language="'javascript'">window.opener.location.href='" + username + "'&Pass='" + pwd + "'; self.close();</script>");

can you correct me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900