Response.Write and UpdatePanel

给你一囗甜甜゛ 提交于 2019-11-27 22:57:05

You can't use Response.Write during an asynchronous postback. Whatever control executes that code needs to be added as a PostBackTrigger in the update panel:

<Triggers>        
    <asp:PostBackTrigger ControlID="Button1" />
</Triggers>

You can also do it in code-behind, if you prefer:

ScriptManager.GetCurrent().RegisterPostBackControl(Button1);

Response.Write will not work under Asynchronous Events. My suggestion is to remove the Update Panel in case it is specifically being used for VCard point of view only.

Alternatively - Place a control inside the Update Panel and initialize it's value under asynchronous event. Now it will work.

Why don't you consider the use of a separate handler/page to serve the vcard?

This is maybe the easiest and cleaner way to do that and it doesnt interfere any other (async or not) postback related to the updatepanel.

user2000095-tim

I had a similar problem with Response.Write. I found a workaround or maybe even a solution to this problem. Capture the TextWriter given to the RenderBeginTag of a server control and write to that.

I blogged with an example here: http://timscyclingblog.wordpress.com/2013/03/07/asp-net-web-forms-response-write-in-an-updatepanel-dev-web/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!