Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Disable Submit Button

Reply
Thread Tools

Disable Submit Button

 
 
jack-e
Guest
Posts: n/a
 
      06-20-2005
Hi,

Can someone please provide me with an example of how to disable the
submit button once clicked (using javascript i guess). Keep in mind I
also have to invoke a server side function which processes the form.

Thanks in advance.

Jack

 
Reply With Quote
 
 
 
 
Craig Deelsnyder
Guest
Posts: n/a
 
      06-20-2005
jack-e wrote:
> Hi,
>
> Can someone please provide me with an example of how to disable the
> submit button once clicked (using javascript i guess). Keep in mind I
> also have to invoke a server side function which processes the form.
>
> Thanks in advance.
>
> Jack
>


Use the Attributes collection to set the onclick to disabled the button
and submit normally:

button1.Attributes.Add("onclick","javascript:docum ent.getElementById('"
+ button1.ClientID + "').disabled=true;" +
this.GetPostBackEventReference(button1));

reference:

http://www.codeproject.com/useritems...bmitButton.asp

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      06-20-2005
Much shorter form:

button1.Attributes.Add("onclick","this.disabled=tr ue;return true;");

Eliyahu

"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
news:(E-Mail Removed)...
> jack-e wrote:
> > Hi,
> >
> > Can someone please provide me with an example of how to disable the
> > submit button once clicked (using javascript i guess). Keep in mind I
> > also have to invoke a server side function which processes the form.
> >
> > Thanks in advance.
> >
> > Jack
> >

>
> Use the Attributes collection to set the onclick to disabled the button
> and submit normally:
>
> button1.Attributes.Add("onclick","javascript:docum ent.getElementById('"
> + button1.ClientID + "').disabled=true;" +
> this.GetPostBackEventReference(button1));
>
> reference:
>
> http://www.codeproject.com/useritems...bmitButton.asp
>
> --
> Craig Deelsnyder
> Microsoft MVP - ASP/ASP.NET



 
Reply With Quote
 
Craig Deelsnyder
Guest
Posts: n/a
 
      06-20-2005
Eliyahu Goldin wrote:
> Much shorter form:
>
> button1.Attributes.Add("onclick","this.disabled=tr ue;return true;");
>
> Eliyahu
>
> "Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
> news:(E-Mail Removed)...
>
>>jack-e wrote:
>>
>>>Hi,
>>>
>>>Can someone please provide me with an example of how to disable the
>>>submit button once clicked (using javascript i guess). Keep in mind I
>>>also have to invoke a server side function which processes the form.
>>>
>>>Thanks in advance.
>>>
>>>Jack
>>>

>>
>>Use the Attributes collection to set the onclick to disabled the button
>>and submit normally:
>>
>>button1.Attributes.Add("onclick","javascript:doc ument.getElementById('"
>>+ button1.ClientID + "').disabled=true;" +
>>this.GetPostBackEventReference(button1));
>>
>>reference:
>>
>>http://www.codeproject.com/useritems...bmitButton.asp
>>
>>--
>>Craig Deelsnyder
>>Microsoft MVP - ASP/ASP.NET

>
>
>


Hmmm, that didn't seem to work for me. Could you provide sample code if
so? For completeness here....

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      06-20-2005
Try to submit the from and then to disable the button. If you disable first
the button, the button is not considered pressed (disabled control are not
posted).

Patrice

--

"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> a écrit dans le message
de news:%(E-Mail Removed)...
> Eliyahu Goldin wrote:
> > Much shorter form:
> >
> > button1.Attributes.Add("onclick","this.disabled=tr ue;return true;");
> >
> > Eliyahu
> >
> > "Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
> > news:(E-Mail Removed)...
> >
> >>jack-e wrote:
> >>
> >>>Hi,
> >>>
> >>>Can someone please provide me with an example of how to disable the
> >>>submit button once clicked (using javascript i guess). Keep in mind I
> >>>also have to invoke a server side function which processes the form.
> >>>
> >>>Thanks in advance.
> >>>
> >>>Jack
> >>>
> >>
> >>Use the Attributes collection to set the onclick to disabled the button
> >>and submit normally:
> >>
> >>button1.Attributes.Add("onclick","javascript:doc ument.getElementById('"
> >>+ button1.ClientID + "').disabled=true;" +
> >>this.GetPostBackEventReference(button1));
> >>
> >>reference:
> >>
> >>http://www.codeproject.com/useritems...bmitButton.asp
> >>
> >>--
> >>Craig Deelsnyder
> >>Microsoft MVP - ASP/ASP.NET

> >
> >
> >

>
> Hmmm, that didn't seem to work for me. Could you provide sample code if
> so? For completeness here....
>
> --
> Craig Deelsnyder
> Microsoft MVP - ASP/ASP.NET



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      06-20-2005
Craig,

You can check it on any server-side button. "this" is the client-side
reference to the button itself and "return true" takes care about bubbling
the event up.

Eliyahu

"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
news:%(E-Mail Removed)...
> Eliyahu Goldin wrote:
> > Much shorter form:
> >
> > button1.Attributes.Add("onclick","this.disabled=tr ue;return true;");
> >
> > Eliyahu
> >
> > "Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
> > news:(E-Mail Removed)...
> >
> >>jack-e wrote:
> >>
> >>>Hi,
> >>>
> >>>Can someone please provide me with an example of how to disable the
> >>>submit button once clicked (using javascript i guess). Keep in mind I
> >>>also have to invoke a server side function which processes the form.
> >>>
> >>>Thanks in advance.
> >>>
> >>>Jack
> >>>
> >>
> >>Use the Attributes collection to set the onclick to disabled the button
> >>and submit normally:
> >>
> >>button1.Attributes.Add("onclick","javascript:doc ument.getElementById('"
> >>+ button1.ClientID + "').disabled=true;" +
> >>this.GetPostBackEventReference(button1));
> >>
> >>reference:
> >>
> >>http://www.codeproject.com/useritems...bmitButton.asp
> >>
> >>--
> >>Craig Deelsnyder
> >>Microsoft MVP - ASP/ASP.NET

> >
> >
> >

>
> Hmmm, that didn't seem to work for me. Could you provide sample code if
> so? For completeness here....
>
> --
> Craig Deelsnyder
> Microsoft MVP - ASP/ASP.NET



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      06-20-2005
Could be. This I didn't check. I've just optimized the size of the code.

Eliyahu

"Patrice" <(E-Mail Removed)> wrote in message
news:eFj%(E-Mail Removed)...
> Try to submit the from and then to disable the button. If you disable

first
> the button, the button is not considered pressed (disabled control are not
> posted).
>
> Patrice
>
> --
>
> "Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> a écrit dans le

message
> de news:%(E-Mail Removed)...
> > Eliyahu Goldin wrote:
> > > Much shorter form:
> > >
> > > button1.Attributes.Add("onclick","this.disabled=tr ue;return true;");
> > >
> > > Eliyahu
> > >
> > > "Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
> > > news:(E-Mail Removed)...
> > >
> > >>jack-e wrote:
> > >>
> > >>>Hi,
> > >>>
> > >>>Can someone please provide me with an example of how to disable the
> > >>>submit button once clicked (using javascript i guess). Keep in mind I
> > >>>also have to invoke a server side function which processes the form.
> > >>>
> > >>>Thanks in advance.
> > >>>
> > >>>Jack
> > >>>
> > >>
> > >>Use the Attributes collection to set the onclick to disabled the

button
> > >>and submit normally:
> > >>

> >
>>button1.Attributes.Add("onclick","javascript:doc ument.getElementById('"
> > >>+ button1.ClientID + "').disabled=true;" +
> > >>this.GetPostBackEventReference(button1));
> > >>
> > >>reference:
> > >>
> > >>http://www.codeproject.com/useritems...bmitButton.asp
> > >>
> > >>--
> > >>Craig Deelsnyder
> > >>Microsoft MVP - ASP/ASP.NET
> > >
> > >
> > >

> >
> > Hmmm, that didn't seem to work for me. Could you provide sample code if
> > so? For completeness here....
> >
> > --
> > Craig Deelsnyder
> > Microsoft MVP - ASP/ASP.NET

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
submit the form data to the popup window without a submit button jrefactors@hotmail.com HTML 2 01-01-2005 06:07 AM
Preventing Multiple submit (Disabling Submit Button Post Click) Solution Mark ASP .Net 1 12-13-2004 08:03 PM
Disable Submit Button on Post back and On Submit in ASP.net Ghafran Abbas ASP .Net 0 10-12-2004 06:11 PM
If value in name field in top row disable submit button until add button is pressed or field is cleared. Chuck Javascript 0 11-10-2003 02:23 AM
Disable Submit Button until Accept Terms and Redirect Page on Submit Paul Oakfleet Javascript 1 09-10-2003 06:07 PM



Advertisments