如何通过使用c#在asp.net中单击子窗口来传递用户名和密码 [英] how to pass user name and password by clicking on child window in asp.net with c#

查看:66
本文介绍了如何通过使用c#在asp.net中单击子窗口来传递用户名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IAM在C#中使用asp.net3.5,
在我的网站上,当我单击该按钮时,它将打开另一个网站的子窗口,但是我想传递用户名和密码,以便我可以直接转到该链接.

以下是我打开子窗口的代码,任何机构都可以帮助我直接传递用户名和密码,以便直接打开链接.


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 = "http://10.15.7.38/boxmachine-layout/HQIT159";
       string fullURL = "window.open('" + 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);

推荐答案


您可以通过多种方式来做到这一点:
1)Javascript查询字符串:
在子窗口中单击按钮时,只需使用以下命令:
Hi,
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>");


但这不是一个好习惯.
2)会议:
如果您确实要发送用户名和密码,请通过会话发送.
点击链接以使用会话变量:
使用Facade设计模式管理ASP.NET会话变量 [ ^ ]
http://msdn.microsoft.com/en-us/library/ms178581.aspx [ ^ ]

祝一切顺利.
--AK


But this will not be a good practice.
2)Session:
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[^]
http://msdn.microsoft.com/en-us/library/ms178581.aspx[^]

All the best.
--AK


这篇关于如何通过使用c#在asp.net中单击子窗口来传递用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆