在asp.net C#的新页面中打开最新记录的id
本文关键字:最新 新记录 id 新页面 asp net | 更新日期: 2023-09-27 18:21:21
我想在数据库中保存信息,并将保存的行的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);
}
使用此
ClientScript.RegisterStartupScript(this.GetType(), "Message", "window.open('../ExportReport/DirectAWB.aspx','_blank');", true);
还要确保您在window.open.
我找到了解决方案必须设置新页面的宽度和高度,如
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);