submit button - custom javascript

G

Guest

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!
 
P

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: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
G

Guest

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!
 
S

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: <[email protected]>
| References: <[email protected]>
<[email protected]>
| 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: <#[email protected]>
| 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!
|
| | > 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: (e-mail address removed)
| > Creator of "Professional Validation And More" at
| > http://www.peterblum.com/vam/home.aspx
| >
| > | >> 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!
| >>
| >
| >
|
|
|
 
G

Guest

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!
 
S

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: <[email protected]>
| References: <[email protected]>
<[email protected]>
<#[email protected]>
<[email protected]>
| 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: <[email protected]>
| 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
| 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!
|
| | > 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: <[email protected]>
| > | References: <[email protected]>
| > <[email protected]>
| > | 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: <#[email protected]>
| > | 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!
| > |
| > | | > | > 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: (e-mail address removed)
| > | > Creator of "Professional Validation And More" at
| > | > http://www.peterblum.com/vam/home.aspx
| > | >
| > | > | > | >> 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!
| > | >>
| > | >
| > | >
| > |
| > |
| > |
| >
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,607
Members
45,240
Latest member
pashute

Latest Threads

Top