我试图找出如何正确编写jQuery代码,以便我可以从后面的ASP.NET代码中调用它.
我不希望它被jQuery click事件触发,我想触发jQuery函数—>“在我的控件后面的代码中显示对话框”.
$(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
我尝试过这样的事情,但它对我不起作用
$(document).ready(function () {
$("#LinkButton1").click(function () {
$("#hightlight_show1").toggle();
});
var dialog1 = $("#Add").dialog({
autoOpen: false,height: 400
});
// Move the dialog back into the
我在使用Page.ClientScript.RegisterStartupScript()的代码中指定了这个.
Page.ClientScript.RegisterStartupScript(
this.GetType(),"a","a();",true
);
最佳答案
@H_403_30@首先,将您的函数a(){移出$(document).ready().
但是,您可能仍然遇到执行顺序问题.
如果这是一个完整的回发,那么使用另一个$(document).ready()将Register(同步)中的a()调用包装起来.如果它是UpdatePanel的部分回发,只要在第一次加载页面时正确创建了对话框,它就应该可以正常工作.