如何在asp.net中打开新的浏览器窗口 [英] how to open new browser window in asp .net

查看:82
本文介绍了如何在asp.net中打开新的浏览器窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生

我希望当用户在asp .net中单击网格视图"的模板按钮时,应该打开一个新的浏览器.我已经完成了该项目,但是问题是,当我第一次单击按钮时,新窗口没有打开,而第二次单击时,它正在工作.您能解决这个问题吗?我已经在下面编写了代码.

Sir

I want that when a user click on template button of Grid View in asp .net a new browser should open. I have done the project but the problem is that when i am clicking on button for the first time new window is not opening and on second click it is working.Can you please solve the problem ? I have written the code below..

protected void gvEmployer_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        
        if (e.CommandName =="cmdDetails")
        {
            int index =Convert.ToInt32(e.CommandArgument);
            Button btn = (Button)gvEmployer.Rows[index].FindControl("btnDetails");
            btn.Attributes.Add("onClick", "window.open('detailsofjobseeker.aspx', '', '', 'height=200,width=400'); return false");
        }
      
    }

推荐答案

Sashibhusan Meher,

这是因为您需要一次将脚本注册到DOM,请尝试执行以下操作

在javascript函数中编写window.open代码
喜欢

hi Sashibhusan Meher,

This is because you need to register the script once to DOM, Try doing the below things

write the window.open code in a javascript function
like

<script language="javascript">
function popUp()
{
window.open('detailsofjobseeker.aspx', '', '', 'height=200,width=400'); return false;
}
</script>



然后在pageLoad()
这样写..



then in pageLoad()
write like this..

protected void Page_Load(object sender, EventArgs e)
        {
         String name1 = "PopupScript";
         String text1 = "<script type=\"text/javascript\">popUp();";
         RegisterStartupScript(name1, text1);
        }



并在通话时..这样写



and while calling.. write like this

btn.Attributes.Add("onClick", "popUp();");



它可能会起作用.

谢谢.



it may work.

Thanks.


这篇关于如何在asp.net中打开新的浏览器窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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