单击按钮如何打开新窗口 [英] how to open new window on click of button

查看:71
本文介绍了单击按钮如何打开新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨......
有人可以告诉我如何在asp.net 4.0中单击按钮才能打开新窗口.
谢谢....请注意,我不必使用javascript ..

hi....
can anybody tell me how we can open new window on click of button in asp.net 4.0.
thanks....note that I dont Have to used javascript..

推荐答案

<%@ Page Language="C#" %>

<%@ Import namespace="System.Text" %>

<script  runat="server">

void Page_load(object sender, EventArgs e)

{

Button1.Attributes.Add( "onclick", "popWin()" );

}

</script>

<html>

<head>

<script>

function popWin()

{

window.open(''yourpage.aspx");

}

</script>

</head>

<body>

<form  runat="server">

<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Go!">

</form>

</body>

</html>



或者我们可以尝试这个


页面加载. (C#)



or we can try this


Page load. (C#)

protected void Page_Load(object sender, EventArgs e)
     {
       if (!IsPostBack)
       {
         string url = "yourpage_to_open.aspx?querystrings=23";
          
         Button1.Attributes.Add("onclick", "window.open(''" + url + "'', ''_blank'', ''height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,titlebar=no'' );return false;");
       }
     }


ASPX


ASPX

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head  runat="server">
  <title></title>
</head>
<body>
  <form id="form1"  runat="server">
  <div>
    <asp:Button ID="Button1" runat="server" Text="Button" />
  </div>
  </form>
</body>
</html>


This[^] might help you out.


这可能会帮助您,

如何在新的浏览器ASP.NET中打开网页? [
This might help you,

How To Open a Web Page In a New Browser ASP.NET?[^]

:)


这篇关于单击按钮如何打开新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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