【问题标题】:Open latest recorded id in new page asp.net C#在新页面asp.net C#中打开最新记录的id
【发布时间】:2014-11-02 13:56:07
【问题描述】:

我想在数据库中保存信息并将保存的行的 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);

}

【问题讨论】:

  • 请检查是否被视为弹窗,某些浏览器可能会阻止弹窗
  • 不要踩弹窗,浏览器允许弹窗

标签: c# asp.net button webpage


【解决方案1】:

使用这个

ClientScript.RegisterStartupScript(this.GetType(), "Message", "window.open('../ExportReport/DirectAWB.aspx','_blank');", true);

还要确保在 window.open 中提供正确的路径。

【讨论】:

  • 您是否检查过您的浏览器没有阻止弹出窗口?
【解决方案2】:

我找到了解决方案 必须像这样为新页面设置宽度和高度

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);

【讨论】:

    猜你喜欢
    • 2021-06-06
    • 1970-01-01
    • 1970-01-01
    • 2015-11-14
    • 2010-11-06
    • 2017-07-27
    • 2011-05-17
    • 2014-10-11
    相关资源
    最近更新 更多