gpt4 book ai didi

javascript - 响应后调用提醒。结束

转载 作者:行者123 更新时间:2023-11-28 04:24:56 30 4
gpt4 key购买 nike

这是我的代码,我试图在响应后显示警报。但没有显示操作系统警报

string filepath =  ConfigurationManager.AppSettings["USPPath"].ToString() + urlPDF;
FileInfo file = new FileInfo(Server.MapPath(filepath));

if (file.Exists)
{
ClientScript.RegisterStartupScript(this.GetType(), "somekey", "alert('Some data missing!');", true);
Response.ClearContent();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);

Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/pdf";
Response.TransmitFile(file.FullName);
try
{
Response.Flush();
ClientScript.RegisterStartupScript(this.GetType(), "somekeyqw","alert('Some data missing!'); ", true);
// DisplaySucessAlert(true, "Shipping Label downloaded successfully.");
// ScriptManager.RegisterStartupScript(this, this.GetType(), "Popalertxs", "normalalert();", true);
}
finally
{
// DisplaySucessAlert(true, "Shipping Label downloaded successfully.");
// ScriptManager.RegisterStartupScript(this, this.GetType(), "Popalert", "normalalert();", true);
}
}

我使用了更新面板,html 代码看起来像

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="btnuspsgenerate" class="btn-def" runat="server" Text="Download USPS label" OnClick="btnuspsgenerate_Click" />

</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnuspsgenerate" />
</Triggers>
</asp:UpdatePanel>

我的 pdf 文件已下载,但未显示警报。这里我用了很多方法都无法显示alert。

我评论了一些代码,因为它们不起作用

最佳答案

当你使用更新面板时,你不能像这样调用javascript..

尝试以下代码,

string CloseWindow;       
CloseWindow = "alert('Hello World')";
ScriptManager.RegisterStartupScript(UpdatePanelID,UpdatePanelID.GetType(), "CloseWindow", CloseWindow, true);

关于javascript - 响应后调用提醒。结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45142495/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com