Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIDisable Submit buttonDisable Submit button
Previous
 
Next
New Post
8/22/2007 8:16 AM
 

Hi, I was wondering if there is some built in way of disabling a submit button after it has been clicked.
And, if there is no default way, how should I do this.

I found something like this to put in DisableSubmit.js:

function DisableButton() {
    document.forms[0].submit();
    window.setTimeout("disableButton('" + window.event.srcElement.id + "')", 0);
}

function disableButton(buttonID) {
    document.getElementById(buttonID).disabled=true;
}

And then this in the page load:

btnSo.Attributes.Add("onclick", "DisableButton()")

And I thought of something like in the page init:

Dim objCSS As Control = Me.Page.FindControl("CSS")
If Not objCSS Is Nothing Then
    Dim objScript As New HtmlGenericControl("script")
    objScript.Attributes("language") = "javascript"
    objScript.Attributes("type") = "text/javascript"
    objScript.Attributes("src") = "/desktopmodules/[MODULENAME]/DisableSubmit.js"
    objCSS.Controls.AddAt(0, objScript)
End If

But it doesn't seem to work...

 
New Post
8/29/2007 11:39 AM
 

Nothing like this in the clientApi?

Any ideas?

 
New Post
8/29/2007 3:01 PM
 

Noting is built into the ClientAPI to stop a double post.  What you have posted seems like it would work, yet you said it didn't.  Did you get an error?   Do you have a url to review?

[edit]

For applications I work on that I wish to stop a double post, I usually use server-side logic and session state.  The idea is simple.  Every page that renders pushes down the current date in a hidden field  (you could use the ClientAPI for this, by RegisterClientVariable).  On every postback, I check the posted value against what is currently in session state as the lastposedvalue.  If session timestamp less-than posted, allow it through.  when done, assign timestamp to session. 


 
New Post
8/29/2007 3:05 PM
 

Try this out:

System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("if (typeof(Page_ClientValidate) == 'function') { ");
sb.Append("if (Page_ClientValidate() == false) { return false; }} ");
sb.Append("this.value = 'Please wait...';");
sb.Append("this.disabled = true;");
sb.Append(this.Page.GetPostBackEventReference(this.btnSave));
sb.Append(";");
btnSave.Attributes.Add("onclick", sb.ToString());

[edit]

The above code will reset the submit button if client-side form verification returns false.


Vitaly Kozadayev
Principal
Viva Portals, L.L.C.
 
New Post
8/30/2007 4:17 AM
 

Thanks a lot Jon, and especially Vitkoz, very nice solution.

Wouldn't it be a great idea to build a code library with usefull scripts (like this) for DNN somewhere on the site?

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIDisable Submit buttonDisable Submit button


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out