c# - trigger jQuery function from code-behind -


i trying figure out how writhe jquery code can call asp.net code behind.

i don't want triggered jquery click event, want trigger jquery function--->"show dialog" in code behind of control.

$(document).ready(function () {     $("#linkbutton1").click(function(){         $("#hightlight_show1").toggle();     });      var dialog1 = $("#add").dialog({             autoopen: false,             width: 620,             height: 400     });      // move dialog <form> element      dialog1.parent().appendto(jquery("form:first"));      $("#bt_add").click(function () {        $("#add").dialog("open");        return false; }); 

i have tried thing did not work me

$(document).ready(function () {     $("#linkbutton1").click(function () {         $("#hightlight_show1").toggle();     });      var dialog1 = $("#add").dialog({         autoopen: false,         width: 620,         height: 400     });      // move dialog <form> element      dialog1.parent().appendto(jquery("form:first"));      function a() {         $("#add").dialog("open");         return false;     };  }); 

i specify in code behind using page.clientscript.registerstartupscript().

page.clientscript.registerstartupscript(     this.gettype(),     "a",     "a();",     true  ); 

first, move function a() { out of $(document).ready().

but might still have issue order of execution.

if full postback, wrap a() call in registerstartupscript $(document).ready(). if it's partial postback updatepanel, should work long dialog created first time page loaded.


Comments