gpt4 book ai didi

ASP.NET AJAX : Creating a postback

转载 作者:行者123 更新时间:2023-12-02 20:43:43 25 4
gpt4 key购买 nike

我想通过在特定事件发生后将一些 AJAX 插入页面来导致仅发生一次的回发。

目前我有:

string script = "<script language='Javascript'>" +
"__doPostBack('GetSpreadsheet', '');" +
"</script>";

Page.ClientScript.RegisterStartupScript(this.GetType(), "DownloadExcel", script);

但是,在我这样做之后,每个回发都有一个 GetSpreadsheet 事件目标,而不仅仅是第一个。我做错了什么?

最佳答案

尝试使用ScriptManager.RegisterStartupScript Method (Control, Type, String, String, Boolean) .

在备注中,您会找到这段文字,它解释了您所追求的内容。

Startup script blocks that are registered by using this method are sent to the page only when the control that is registering the block is inside an UpdatePanel control that is being updated.

关于ASP.NET AJAX : Creating a postback,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1841316/

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