Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

$4.95 Windows Hosting at Webhost4life.com
  Need Help?  
Professional technical support for DotNetNuke is available from DotNetNuke Corporation.
 


  Ads  
Biz Modules provides professional business modules and solutions for DotNetNuke
 


  Sponsors  

Meet Our Sponsors

Salaro -- Skins and more
OnyakTech
The best choice for your web site host, email hosting, and domain registration.
CrystalTech Web Hosting™
Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
 


DotNetNuke Forums
 
  Forum  DotNetNuke® Pro...  ClientAPI Compo...  Disable Submit button
Previous Previous
 
Next Next
New Post 8/22/2007 5:16 AM
User is offline M Bouwman
199 posts
www.mvic.nl
9th Ranked


Disable Submit button 
Modified By M Bouwman  on 8/22/2007 8:18:39 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 8:39 AM
User is offline M Bouwman
199 posts
www.mvic.nl
9th Ranked


Re: Disable Submit button 

Nothing like this in the clientApi?

Any ideas?

 
New Post 8/29/2007 12:01 PM
User is offline Jon Henning
1605 posts
www.codeendeavors.com
5th Ranked










Re: Disable Submit button 
Modified By Jon Henning  on 8/29/2007 3:04:56 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 12:05 PM
User is offline Vitaly Kozadayev
723 posts
www.continure.com
7th Ranked






Re: Disable Submit button 
Modified By Vitaly Kozadayev  on 8/29/2007 3:10:06 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 1:17 AM
User is offline M Bouwman
199 posts
www.mvic.nl
9th Ranked


Re: Disable Submit button 
Modified By M Bouwman  on 8/30/2007 4:19:52 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 Previous
 
Next Next
  Forum  DotNetNuke® Pro...  ClientAPI Compo...  Disable Submit button
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


T-WORX, INC.
Professional DotNetNuke Solutions
www.t-worx.com
AppTheory
Professional development for medium to large projects based on the DotNetNuke platform.
www.apptheory.com
OnyakTech
Modules for Help Desks, Live Chat, Project Management, CRM, Charting, Reporting, Scrolling Text/Images, Portal Community tools and much more.
www.OnyakTech.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP