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  |  

telerik -- supercharge your DNN websites
  Ads  
Active Modules -- Active Forums for DotNetNuke
 


  Sponsors  

Meet Our Sponsors

ExactTarget email software solutions
Merak Mail Server
WebSecureStores -- ASP.NET & DotNetNuke Hosting Solutions
FCKeditor Project
Salaro -- Skins and more
OnyakTech
 


DotNetNuke Forums
 
  Forum  DotNetNuke® Pro...  ClientAPI Compo...  Disable Submit button
Previous Previous
 
Next Next
New Post 8/22/2007 6:16 AM
User is offline M Bouwman
213 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 9:39 AM
User is offline M Bouwman
213 posts
www.mvic.nl
9th Ranked


Re: Disable Submit button 

Nothing like this in the clientApi?

Any ideas?

 
New Post 8/29/2007 1:01 PM
User is offline Jon Henning
1622 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 1:05 PM
User is offline Vitaly Kozadayev
753 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 2:17 AM
User is offline M Bouwman
213 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.

 


Swirlhost Inc.
Affordable DotNetNuke Hosting, Skin Development, Custom Module Development, and DotNetNuke Consulting. We will install your preference of DNN and now host with us and get a free license for the Swirl AJAX Chatroom Module.
www.swirlhost.com
Active Modules, Inc.
Creators of Active Forums, the best forum module for DotNetNuke
www.activemodules.com
DNNCovered.com - Your Offshore Dotnetnuke Partner
Dnncovered.com is the only Dotnetnuke offshore outsourcing center specializes in DNN skinning and module development with lowest pricing and quality service. Our staff is dedicated to websites based on DNN and our graphic designers are creative and imaginative well enough to provide customers the complete set of skinning solutions and packages
www.dnncovered.com

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