我使用的是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从外面改变它,就像我在答案中解释的那样。 –