2014-10-30 65 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');

感謝大家對你的答案:)