English 中文(简体)
j but球启动器
原标题:jquery button trigger server side onclick event

我在使用jquery dialog时,当用户点击ok时,服务器的侧面应发射,如果取消,就没有发生。

i 从一开始就必须防止Default()功能。

  $(document).ready(function () {
         $("#<%=submit.ClientID %>").click(function (event) {
             event.preventDefault();
                $("#confirm").dialog({
                    buttons: {
                        "OK": function () {  $(this).dialog("close"); 
                              Here should be the code to trigger the server side click event


                     },
                        "Cancel": function () { $(this).dialog("close");},
                    } 
                });
         });
     });

我不知道如何启动服务器边的浮标活动。 是否有任何想法? 感谢

最佳回答
问题回答

Put the event.preventDefault( in the abolition of part or some Forms of conditions for it so it isn trun on each Point.

i think you are confusing between server and client sides. if you want to trigger event on the server side you need to notify him (can be done by ajax call). the click event is a client side event that will not do anything on the server side. try to put some code under the "OK" function to notify the server whatever you want like via ajax call.

anyway you should move the event.preventDefault() call into the "Cancel" function.

edit: another way to approach it is to prevent the submit to happen if you don t want it. at your form tag add onsubmit="foo()" and define:

function foo(){
   //call your dialog and return true to continue the submit and false to cancel.
}

它略微依赖执行细节(即使它们得到如此广泛的使用,以改变其获得的数值),但守则是:

__doPostBack( submit , OnClick );

这将执行<编码>OnClick, 用于控制submit/code>。 参考文献参考了这个关于





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!