我想在数据库中保存信息并将保存的行的ID传递给新页面,然后下一页必须在新窗口中显示此ID。我写了这段代码,但只是保存操作正常,显示新页面不起作用。这是代码:
protected void btnReportWaybill_Click(object sender, EventArgs e)
{
Session["Code"] = null;
string strId = txtCode.Text.Trim();
SaveOperation();
Session["Code"] = strId;
ClientScript.RegisterClientScriptBlock(this.GetType(), "Message", "window.open('../ExportReport/DirectAWB.aspx','_blank');", true);
}
答案 0 :(得分:1)
使用此
ClientScript.RegisterStartupScript(this.GetType(), "Message", "window.open('../ExportReport/DirectAWB.aspx','_blank');", true);
还要确保在window.open中提供正确的路径。
答案 1 :(得分:0)
我找到了解决方案 必须像这样设置新页面的宽度和高度
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);window.open( 'ExportReport/PreManifest.aspx', null, 'height=700,width=760,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,top=\'+Mtop+\', left=\'+Mleft+\'' );", true);