2014-10-30 105 views
-1

我在页面中的更新面板中有一个按钮。在按钮上单击事件dependendant上的文本框输入我建立一个网址,并必须在新窗口中打开该网址。在Asp.net按钮点击打开链接在新的最大化窗口中

我曾尝试:

我)窗口打开..但它打开未最大化,而不是一个完全最大化窗口。我试着把它的高度设置成高亮度,但是这个要求只是完整的窗口,每次我打开窗户都不需要最大化。

<Asp:button OnClick="Btn1_Click" /> 
 

 
//in code behind 
 
protected void Btn1_Click(object sender, EventArgs e) 
 
{ 
 

 
     //my code to generate url 
 

 
// In below lines im trying to open window 
 
//Im ont using OnClientClick becoz..the button is in Update panel 
 
    ScriptManager.RegisterStartupScript(btnLoadReport.Page, 
 
          Btn1.GetType(), "", "window.open('" + myUrl+ "','','height=' + screen.height + ',width=' + screen.width + ',resizable=yes,scrollbar=yes,toolbar=yes,menubar=yes,location=yes,top=0, left=0');", true); 
 
    }  

或者我可以在按钮的单击事件动态创建超链接点击事件..和我如何尝试?

任何想法和样品将不胜感激。

感谢,

艾哈迈德

+0

哦,等等,你说你做的resonse.redirect其尚未运行的OpenURL()函数?当然它没有。如果它已经重定向到不同的页面,它将如何运行。尝试注册脚本。 – TheProvost 2014-10-30 08:17:17

+0

是的,这是一个错误:.....谢谢你们所有人,Window.open对我没有帮助。它会打开弹出窗口。我需要完整(最大化)窗口(不设置hiegth,宽度) – Ahmed 2014-10-30 08:42:08

+0

我不需要弹出窗口(这不是一个完整大小的窗口)。我需要一个最大化的窗口。 – Ahmed 2014-10-30 10:16:51

回答

0

试试这个:OnClientClick="window.open('url')"

+0

我alreday使用..在我的问题中提到它总是打开弹出窗口..我需要整个窗口 – Ahmed 2014-10-30 07:59:06

+0

我发现simmilar问题没有stackoverflow,请检查此请http://stackoverflow.com/questions/10297168/how-to-open-maximized-window-with-javascript – 2014-10-30 08:01:58

+0

谢谢...是的类似的问题。并没有解决 – Ahmed 2014-10-30 08:40:51

0

试试这个请:window.open(url, '_blank');

编辑:看看这个链接花花公子example for opening new tab

+0

这不是帮助我得到最大化窗口:( – Ahmed 2014-10-30 10:18:48

0

你写C#文件,

button.attributes.add(“onclick”,“javascript:function1()”);

在aspx页面

,写javascript函数下面

函数功能1() { window.open(“页面名称”,其他属性,其值要被传递到其他页面); }

0

第一次不明白你的意思。尝试这个。我猜你没有使用更新面板在这里吧?因为如果你是,你应该使用scriptmanger.register ..代替客户端脚本

Btn1_Click() 
{ 

//my code to bulid url 

ClientScript.RegisterStartupScript(this.GetType(),"Redirection","window.open('www.google.com', '_blank')",true); 
} 


<Asp:button OnClick="Btn1_Click" /> 
+0

我使用scriptmanger.register,因为我有即时通讯使用updatepanel – Ahmed 2014-10-30 10:18:12

+0

theres是没有问题现在注册脚本和打开窗口。但我需要一个完全最大化的窗口,这是不是能够与window.open – Ahmed 2014-10-31 04:40:13

0

我的问题得到了解决由参数添加“chromemode = YES” ..像下面..

window.open( url,'chromemode = yes,scrollbars = yes');

感谢大家对你的答案:)