开发者

how to implment click-once submit button in asp.net mvc 2?

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.

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.

thanks!


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.

For example:

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

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

and then in your javascript section:

function disableSubmitButton() {

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

};

Hope this helps.


Here is example of how create ajax login using asp.net mvc and jQuery: How to implement a Client-side Ajax Login on Asp.Net MVC (A link to the solution for Asp.Net Webforms is in here)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜