Asp.net ajax jquery

I have a page that downloads a playlist of songs. Individual songs in the playlist can be dragged around the playlist using jquery. The page also includes server-side sorting using the ajax update panel. the problem is that after server-side sorting, jquery methods no longer work.

are jquery methods re-attached to the document after asp.net ajax panel refreshes the page?

+3
source share
4 answers

There is a problem if we use updatepanel. Therefore, we need to add javascript from the server side every time the page loads. You can do this by adding all your javascript codes to a string variable and adding it with ScriptManager.RegisterStartupScript(this, this.GetType(), "validation", script, false);Go to http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerstartupscript.aspx/ ", to get more information about the function and its arguments.

You can make such a function

 private void addScript()
        {
            string script = @"<script type=""text/javascript"" language=""javascript"">
              javascript function including jquery
               </script>";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "validation", script, false);
        }

All javascript function will be added to the string script. Call the function in pageload. Thus, it will be added to the page again. I think this will solve the problem.

0
source

ajax, jquery, , , , .

ajax-, . - jQuery delegate() , ( ).

+1

jquery asp.net ajax ?

- , document.ready. " " pageLoad. .

0

, .load

$("body").append("<div style='display:none;'></div>");
$("div:last").load("url.aspx?id=1", function(response, status, xml){ ...do stuff });

$.ajax ,

If your update panel is broken, you can still send it back using javascript __doPostBack (elmID, args);

0
source

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


All Articles