ASP.NET postback with JavaScript

2019-01-01 14:49发布

I have several small divs which utilizing jQuery draggable. These divs are placed in an UpdatePanel, and on dragstop I use the _doPostBack() JavaScript function. where i extract necessary information from the pages form.

My problem is that when i call this function the whole page is re-loaded but i only want the update panel to be re-loaded.

8条回答
十年一品温如言
2楼-- · 2019-01-01 15:27

While Phairoh's solution seems theoretically sound, I have also found another solution to this problem. By passing the UpdatePanels id as a paramater (event target) for the doPostBack function the update panel will post back but not the entire page.

__doPostBack('myUpdatePanelId','')

*note: second parameter is for addition event args

hope this helps someone!

EDIT: so it seems this same piece of advice was given above as i was typing :)

查看更多
余欢
3楼-- · 2019-01-01 15:27

If anyone's having trouble with this (as I was), you can get the postback code for a button by adding the UseSubmitBehavior="false" attribute to it. If you examine the rendered source of the button, you'll see the exact javascript you need to execute. In my case it was using the name of the button rather than the id.

查看更多
登录 后发表回答