我使用的是ASP.NET和C#,我使用window.open()打開窗口。現在我需要在該窗口中設置該頁面的寬度。如何在打開窗口時設置頁面大小?
我在buttonclick事件上使用此代碼。
ClientScript.RegisterStartupScript(this.GetType(), "oncl", "<script language=javascript>window.open('Print.aspx','PrintMe','width=900,resizable=1,scrollbars=1');</script>");
腳本內部的寬度僅設置窗口寬度。但我想設置頁面的寬度。
可能嗎?
謝謝..
編輯:
對不起,我沒有提到它before.I我寫的內容轉換成print.aspx dynamically.That我使用這個代碼填充頁面。
Page pg = new Page();
pg.EnableEventValidation = false;
HtmlForm frm = new HtmlForm();
pg.Controls.Add(frm);
frm.Controls.Add(ctrl);
pg.DesignerInitialize();
pg.RenderControl(htmlWrite);
string strHTML = stringWrite.ToString();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(strHTML);
這在pageload事件上被調用。所以我打印print.aspx中的.aspx頁面。所以我想這個內容應該在靜態頁面寬度。
它並不真正的問題,你可以使用JS從外面改變它,就像我在答案中解釋的那樣。 –