I am trying to call a jQuery function from ASP.NET code behind.
I don't want it to be triggered by the jQuery click event; I want to trigger the jQuery function--->"show the dialog" in the code behind of my control.
$(document).ready(function () {
$("#LinkButton1").click(function(){
$("#hightlight_show1").toggle();
});
var dialog1 = $("#Add").dialog({
autoOpen: false,
width: 620,
height: 400
});
// Move the dialog back into the <form> element
dialog1.parent().appendTo(jQuery("form:first"));
$("#BT_add").click(function () {
$("#Add").dialog("open");
return false;
});
I have tried something like this but it did not work:
$(document).ready(function () {
$("#LinkButton1").click(function () {
$("#hightlight_show1").toggle();
});
var dialog1 = $("#Add").dialog({
autoOpen: false,
width: 620,
height: 400
});
// Move the dialog back into the <form> element
dialog1.parent().appendTo(jQuery("form:first"));
function a() {
$("#Add").dialog("open");
return false;
};
});
I specify this in the code behind using Page.ClientScript.RegisterStartupScript():
Page.ClientScript.RegisterStartupScript(
this.GetType(),
"a",
"a();",
true
);