Home All Groups Group Topic Archive Search About

submit button - custom javascript

Author
10 Oct 2005 8:23 PM
param
Hi all,

Has anyone been able to write some custom javascript on the onclick event of
submit button to do certain things like disable submit button, only submit
form once etc. This was a breeze in 1.1 since I could edit the .js file. Now
in 2.0 I can no longer do this. Also, my code would have to be called after
all client-side validation was done and was successful. Any ideas?

TIA!

Author
10 Oct 2005 10:25 PM
Peter Blum
The Button control now offers a property called OnClientClick where you add
your own javascript that doesn't interfere with client-side validation.
However, when it comes to disabling buttons, you need it to run after
validation completes AND after the form actually submits. Putting it into
the button's code is too early. Consider using
Page.ClientScript.RegisterOnSubmitStatement to fire some code using the
javascript code "window.setTimeout(10, your code here);" The major problem
is that you don't have control over the order this statement will be fired.
The validators also use RegisterOnSubmitStatement to validate. If your code
runs first and validation fails, it will disable buttons when the page isn't
submitted.

I solved this by writing a replacement to the ASP.NET validators called
"Professional Validation And More" (http://www.peterblum.com/vam/home.aspx)
which gives you greatly expanded validation technology including buttons
that know how to disable themselves upon submission (after validation runs.)

--- Peter Blum
www.PeterBlum.com
Email: PLB***@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

<param@community.nospam> wrote in message
Show quoteHide quote
news:O7vkthdzFHA.1168@TK2MSFTNGP10.phx.gbl...
> Hi all,
>
> Has anyone been able to write some custom javascript on the onclick event
> of submit button to do certain things like disable submit button, only
> submit form once etc. This was a breeze in 1.1 since I could edit the .js
> file. Now in 2.0 I can no longer do this. Also, my code would have to be
> called after all client-side validation was done and was successful. Any
> ideas?
>
> TIA!
>
Are all your drivers up to date? click for free checkup

Author
11 Oct 2005 4:05 PM
param
I wish MS would pay more attention on how their platform is being used in a
"real-world" environment before going around changing stuff and complicating
things. That would be a big drawback for us in upgrading our apps to 2.0,
since most of our users are typical end-users and love clicking on buttons..

thanks!

Show quoteHide quote
"Peter Blum" <PLB***@Blum.info> wrote in message
news:OTkcQlezFHA.3836@TK2MSFTNGP10.phx.gbl...
> The Button control now offers a property called OnClientClick where you
> add your own javascript that doesn't interfere with client-side
> validation. However, when it comes to disabling buttons, you need it to
> run after validation completes AND after the form actually submits.
> Putting it into the button's code is too early. Consider using
> Page.ClientScript.RegisterOnSubmitStatement to fire some code using the
> javascript code "window.setTimeout(10, your code here);" The major problem
> is that you don't have control over the order this statement will be
> fired. The validators also use RegisterOnSubmitStatement to validate. If
> your code runs first and validation fails, it will disable buttons when
> the page isn't submitted.
>
> I solved this by writing a replacement to the ASP.NET validators called
> "Professional Validation And More"
> (http://www.peterblum.com/vam/home.aspx) which gives you greatly expanded
> validation technology including buttons that know how to disable
> themselves upon submission (after validation runs.)
>
> --- Peter Blum
> www.PeterBlum.com
> Email: PLB***@PeterBlum.com
> Creator of "Professional Validation And More" at
> http://www.peterblum.com/vam/home.aspx
>
> <param@community.nospam> wrote in message
> news:O7vkthdzFHA.1168@TK2MSFTNGP10.phx.gbl...
>> Hi all,
>>
>> Has anyone been able to write some custom javascript on the onclick event
>> of submit button to do certain things like disable submit button, only
>> submit form once etc. This was a breeze in 1.1 since I could edit the .js
>> file. Now in 2.0 I can no longer do this. Also, my code would have to be
>> called after all client-side validation was done and was successful. Any
>> ideas?
>>
>> TIA!
>>
>
>
Author
12 Oct 2005 2:30 AM
Steven Cheng[MSFT]
Hi Param,

Thanks for your sincere advice and feedback on the ASP.NET 2.0 control.
Yes, sometimes the new modification of the new version may break the
previous programming model/style and that's also the pain of some other
developers. However, most of the changes are also comming from the feedback
and inputs from the customers and community, and our dev guys will really
be happy to accept more advice and suggestions from the users so as to make
them better and better.  Anyway, thanks again for your inputs and we really
appreciate such comments and feedback since they're our invaluable resource.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
--------------------
| From: <param@community.nospam>
| References: <O7vkthdzFHA.1***@TK2MSFTNGP10.phx.gbl>
<OTkcQlezFHA.3***@TK2MSFTNGP10.phx.gbl>
| Subject: Re: submit button - custom javascript
| Date: Tue, 11 Oct 2005 11:05:07 -0500
| Lines: 50
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| X-RFC2646: Format=Flowed; Response
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| Message-ID: <#d3eO2nzFHA.4***@TK2MSFTNGP15.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: corp2.lazardgroup.com 70.182.148.88
| Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP1
5.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:350033
Show quoteHide quote
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I wish MS would pay more attention on how their platform is being used in
a
| "real-world" environment before going around changing stuff and
complicating
| things. That would be a big drawback for us in upgrading our apps to 2.0,
| since most of our users are typical end-users and love clicking on
buttons..
|
| thanks!
|
| "Peter Blum" <PLB***@Blum.info> wrote in message
| news:OTkcQlezFHA.3836@TK2MSFTNGP10.phx.gbl...
| > The Button control now offers a property called OnClientClick where you
| > add your own javascript that doesn't interfere with client-side
| > validation. However, when it comes to disabling buttons, you need it to
| > run after validation completes AND after the form actually submits.
| > Putting it into the button's code is too early. Consider using
| > Page.ClientScript.RegisterOnSubmitStatement to fire some code using the
| > javascript code "window.setTimeout(10, your code here);" The major
problem
| > is that you don't have control over the order this statement will be
| > fired. The validators also use RegisterOnSubmitStatement to validate.
If
| > your code runs first and validation fails, it will disable buttons when
| > the page isn't submitted.
| >
| > I solved this by writing a replacement to the ASP.NET validators called
| > "Professional Validation And More"
| > (http://www.peterblum.com/vam/home.aspx) which gives you greatly
expanded
| > validation technology including buttons that know how to disable
| > themselves upon submission (after validation runs.)
| >
| > --- Peter Blum
| > www.PeterBlum.com
| > Email: PLB***@PeterBlum.com
| > Creator of "Professional Validation And More" at
| > http://www.peterblum.com/vam/home.aspx
| >
| > <param@community.nospam> wrote in message
| > news:O7vkthdzFHA.1168@TK2MSFTNGP10.phx.gbl...
| >> Hi all,
| >>
| >> Has anyone been able to write some custom javascript on the onclick
event
| >> of submit button to do certain things like disable submit button, only
| >> submit form once etc. This was a breeze in 1.1 since I could edit the
.js
| >> file. Now in 2.0 I can no longer do this. Also, my code would have to
be
| >> called after all client-side validation was done and was successful.
Any
| >> ideas?
| >>
| >> TIA!
| >>
| >
| >
|
|
|
Author
14 Oct 2005 1:46 PM
param
Hi Steve, so what is the workaround so that I can accomplish what I want to
do without writing any complicated custom validators etc. Any ideas?

TIA!

Show quoteHide quote
"Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message
news:MVD7yTtzFHA.3464@TK2MSFTNGXA02.phx.gbl...
> Hi Param,
>
> Thanks for your sincere advice and feedback on the ASP.NET 2.0 control.
> Yes, sometimes the new modification of the new version may break the
> previous programming model/style and that's also the pain of some other
> developers. However, most of the changes are also comming from the
> feedback
> and inputs from the customers and community, and our dev guys will really
> be happy to accept more advice and suggestions from the users so as to
> make
> them better and better.  Anyway, thanks again for your inputs and we
> really
> appreciate such comments and feedback since they're our invaluable
> resource.
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> --------------------
> | From: <param@community.nospam>
> | References: <O7vkthdzFHA.1***@TK2MSFTNGP10.phx.gbl>
> <OTkcQlezFHA.3***@TK2MSFTNGP10.phx.gbl>
> | Subject: Re: submit button - custom javascript
> | Date: Tue, 11 Oct 2005 11:05:07 -0500
> | Lines: 50
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
> | X-RFC2646: Format=Flowed; Response
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
> | Message-ID: <#d3eO2nzFHA.4***@TK2MSFTNGP15.phx.gbl>
> | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | NNTP-Posting-Host: corp2.lazardgroup.com 70.182.148.88
> | Path:
> TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP1
> 5.phx.gbl
> | Xref: TK2MSFTNGXA02.phx.gbl
> microsoft.public.dotnet.framework.aspnet:350033
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> |
> | I wish MS would pay more attention on how their platform is being used
> in
> a
> | "real-world" environment before going around changing stuff and
> complicating
> | things. That would be a big drawback for us in upgrading our apps to
> 2.0,
> | since most of our users are typical end-users and love clicking on
> buttons..
> |
> | thanks!
> |
> | "Peter Blum" <PLB***@Blum.info> wrote in message
> | news:OTkcQlezFHA.3836@TK2MSFTNGP10.phx.gbl...
> | > The Button control now offers a property called OnClientClick where
> you
> | > add your own javascript that doesn't interfere with client-side
> | > validation. However, when it comes to disabling buttons, you need it
> to
> | > run after validation completes AND after the form actually submits.
> | > Putting it into the button's code is too early. Consider using
> | > Page.ClientScript.RegisterOnSubmitStatement to fire some code using
> the
> | > javascript code "window.setTimeout(10, your code here);" The major
> problem
> | > is that you don't have control over the order this statement will be
> | > fired. The validators also use RegisterOnSubmitStatement to validate.
> If
> | > your code runs first and validation fails, it will disable buttons
> when
> | > the page isn't submitted.
> | >
> | > I solved this by writing a replacement to the ASP.NET validators
> called
> | > "Professional Validation And More"
> | > (http://www.peterblum.com/vam/home.aspx) which gives you greatly
> expanded
> | > validation technology including buttons that know how to disable
> | > themselves upon submission (after validation runs.)
> | >
> | > --- Peter Blum
> | > www.PeterBlum.com
> | > Email: PLB***@PeterBlum.com
> | > Creator of "Professional Validation And More" at
> | > http://www.peterblum.com/vam/home.aspx
> | >
> | > <param@community.nospam> wrote in message
> | > news:O7vkthdzFHA.1168@TK2MSFTNGP10.phx.gbl...
> | >> Hi all,
> | >>
> | >> Has anyone been able to write some custom javascript on the onclick
> event
> | >> of submit button to do certain things like disable submit button,
> only
> | >> submit form once etc. This was a breeze in 1.1 since I could edit the
> js
> | >> file. Now in 2.0 I can no longer do this. Also, my code would have to
> be
> | >> called after all client-side validation was done and was successful.
> Any
> | >> ideas?
> | >>
> | >> TIA!
> | >>
> | >
> | >
> |
> |
> |
>
Author
17 Oct 2005 2:13 AM
Steven Cheng[MSFT]
Thanks for your response Param,

Currently as for your scenario, I think Peter's suggestion is reasonable.
For normal operation before button postback, we can just use the Clientside
OnClientClick  event to register our clientscript. If we need to do some
global script operation after the valication controls' client validation
and before the page postback, we can utilize the form's "onsubmit" client
event.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: <param@community.nospam>
| References: <O7vkthdzFHA.1***@TK2MSFTNGP10.phx.gbl>
<OTkcQlezFHA.3***@TK2MSFTNGP10.phx.gbl>
<#d3eO2nzFHA.4***@TK2MSFTNGP15.phx.gbl>
<MVD7yTtzFHA.3***@TK2MSFTNGXA02.phx.gbl>
| Subject: Re: submit button - custom javascript
| Date: Fri, 14 Oct 2005 08:46:19 -0500
| Lines: 122
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| X-RFC2646: Format=Flowed; Original
| Message-ID: <ucNTpWM0FHA.3***@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: corp.lazardgroup.com 64.237.78.178
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:131384
Show quoteHide quote
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi Steve, so what is the workaround so that I can accomplish what I want
to
| do without writing any complicated custom validators etc. Any ideas?
|
| TIA!
|
| "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message
| news:MVD7yTtzFHA.3464@TK2MSFTNGXA02.phx.gbl...
| > Hi Param,
| >
| > Thanks for your sincere advice and feedback on the ASP.NET 2.0 control.
| > Yes, sometimes the new modification of the new version may break the
| > previous programming model/style and that's also the pain of some other
| > developers. However, most of the changes are also comming from the
| > feedback
| > and inputs from the customers and community, and our dev guys will
really
| > be happy to accept more advice and suggestions from the users so as to
| > make
| > them better and better.  Anyway, thanks again for your inputs and we
| > really
| > appreciate such comments and feedback since they're our invaluable
| > resource.
| >
| > Regards,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > --------------------
| > | From: <param@community.nospam>
| > | References: <O7vkthdzFHA.1***@TK2MSFTNGP10.phx.gbl>
| > <OTkcQlezFHA.3***@TK2MSFTNGP10.phx.gbl>
| > | Subject: Re: submit button - custom javascript
| > | Date: Tue, 11 Oct 2005 11:05:07 -0500
| > | Lines: 50
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| > | X-RFC2646: Format=Flowed; Response
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| > | Message-ID: <#d3eO2nzFHA.4***@TK2MSFTNGP15.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: corp2.lazardgroup.com 70.182.148.88
| > | Path:
| >
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP1
Show quoteHide quote
| > 5.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:350033
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | I wish MS would pay more attention on how their platform is being
used
| > in
| > a
| > | "real-world" environment before going around changing stuff and
| > complicating
| > | things. That would be a big drawback for us in upgrading our apps to
| > 2.0,
| > | since most of our users are typical end-users and love clicking on
| > buttons..
| > |
| > | thanks!
| > |
| > | "Peter Blum" <PLB***@Blum.info> wrote in message
| > | news:OTkcQlezFHA.3836@TK2MSFTNGP10.phx.gbl...
| > | > The Button control now offers a property called OnClientClick where
| > you
| > | > add your own javascript that doesn't interfere with client-side
| > | > validation. However, when it comes to disabling buttons, you need
it
| > to
| > | > run after validation completes AND after the form actually submits.
| > | > Putting it into the button's code is too early. Consider using
| > | > Page.ClientScript.RegisterOnSubmitStatement to fire some code using
| > the
| > | > javascript code "window.setTimeout(10, your code here);" The major
| > problem
| > | > is that you don't have control over the order this statement will be
| > | > fired. The validators also use RegisterOnSubmitStatement to
validate.
| > If
| > | > your code runs first and validation fails, it will disable buttons
| > when
| > | > the page isn't submitted.
| > | >
| > | > I solved this by writing a replacement to the ASP.NET validators
| > called
| > | > "Professional Validation And More"
| > | > (http://www.peterblum.com/vam/home.aspx) which gives you greatly
| > expanded
| > | > validation technology including buttons that know how to disable
| > | > themselves upon submission (after validation runs.)
| > | >
| > | > --- Peter Blum
| > | > www.PeterBlum.com
| > | > Email: PLB***@PeterBlum.com
| > | > Creator of "Professional Validation And More" at
| > | > http://www.peterblum.com/vam/home.aspx
| > | >
| > | > <param@community.nospam> wrote in message
| > | > news:O7vkthdzFHA.1168@TK2MSFTNGP10.phx.gbl...
| > | >> Hi all,
| > | >>
| > | >> Has anyone been able to write some custom javascript on the onclick
| > event
| > | >> of submit button to do certain things like disable submit button,
| > only
| > | >> submit form once etc. This was a breeze in 1.1 since I could edit
the
| > js
| > | >> file. Now in 2.0 I can no longer do this. Also, my code would have
to
| > be
| > | >> called after all client-side validation was done and was
successful.
| > Any
| > | >> ideas?
| > | >>
| > | >> TIA!
| > | >>
| > | >
| > | >
| > |
| > |
| > |
| >
|
|
|

Bookmark and Share