Updating UpdatePanel without a start button

I have an UpdatePanel with the specified ContentTemplate. When the page loads, the user can do some AJAX work in another part of the page. Then, after the work is completed, I would like to update only the content inside the UpdatePanel, but without pressing any buttons, etc. I have to be done automatically using JavaScript when AJAX has been started before. How to do this without manually pressing the trigger button?

EDIT:

Ok, I followed this _doPostBack rule and the whole page was published.

<asp:UpdatePanel ID="panelAttachments" runat="server"> <ContentTemplate> ........ </ContentTemplate> </asp:UpdatePanel> <input type="text" name="test" onchange="__doPostBack('<%=panelAttachments.UniqueID %>',''); return false;" /> </td> 

Thanks Pawel

+4
source share
1 answer

To update the update panel from javascript:

__doPostBack(updatePanelUniqueID,'');

The first parameter is the UniqueID (not CientID) UpdatePanel. The second parameter is optional arguments that you can pass that will be available for your server code. Both are stored in hidden forms of an ASP.NET form, you can access them in code:

 Request.Form["__EVENTTARGET"]; Request.Form["__EVENTARGUMENT"]; 

But if you just want to update the panel and do not need to pass any additional information from the client, you can ignore the second argument.

If you look at the HTML generated by ASP.NET for managing async feedback, you will see it that way.

+7
source

Source: https://habr.com/ru/post/1335243/


All Articles