如何implment点击一次在asp.net MVC 2的提交按钮? [英] how to implment click-once submit button in asp.net mvc 2?

查看:98
本文介绍了如何implment点击一次在asp.net MVC 2的提交按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现一个点击一次按钮,我的asp.net MVC 2的应用程序。我刚才一个非常简单的提交表单,当用户点击提交按钮,我需要它的形象改变为请稍候...类型的图形和禁用click事件作进一步提交,直到服务器恢复

I need to implement a click-once button for my asp.net mvc 2 application. I have just a very simple submit form, and when the user clicks on the submit button, I need to change its image to a "please wait..." type of graphics and disables the click event for further submits until the server comes back.

是否有这样的一个例子或code段?我曾经是能够做到在asp.net web表单,但该技术在这里并不适用。

Is there an example or code snippet for this? I used to be able to do it in the asp.net webforms, but that technique does not apply here.

谢谢!

推荐答案

要禁用,当您提交表单可以使用的onsubmit函数的形式和调用JavaScript函数,将禁用按钮提交按钮。

To disable the submit button when you submit the form you can use the onSubmit function for the form and call a javascript function that will disable the button.

例如:

<% using (Html.BeginForm("Create", "Organisation", FormMethod.Post, new { autocomplete = "off", onsubmit = "disableSubmitButton()" }))
   { %>
       //Your code

      <input id="buttonName" type="submit" value="Create"/>
  <% } %>

,然后在你的JavaScript部分:

and then in your javascript section:

function disableSubmitButton() {

    document.getElementById("buttonName").disabled = true;

};

希望这有助于。

这篇关于如何implment点击一次在asp.net MVC 2的提交按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆