469,572 Members | 1,325 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

YES/NO confirmation + Validation control

Hi,

I want to have confirmation(Yes/No) on a button of the webform in which
there are many validation controls. I want all the validation controls to be
triggered first and then Yes/No confirmation message. By adding just an
confirm attribute for 'onclick' event of the button doesn't work with
validation controls. Is there any short way to go around this.

Thanks
Nedu

Nov 18 '05 #1
6 3503
Nedu,

I created a disable submit javascript that keeps a user from clicking the
submit button a second time.

The part of the script that will interest you is that I'm tying in to the
..Net validation script in order to check that the submit button doesn't get
disabled when the page isn't valid.

I think you could modify it to do what you need.

Here's the script (I've placed a comment line in the "checkSubmit" function
in the script where I think you could add your alert):

<script language="javascript">
<!--
var submitcount=0;

function disableSubmit()
{
if (typeof(Page_ClientValidate)=='function')
{
if (Page_ClientValidate() == true)
{
return checkSubmit();
}
else
{
return true;
}
}
else
{
return checkSubmit();
}
}

function checkSubmit()
{
if (submitcount == 0)
{
submitcount++; return true; //You could add your alert here.
}
else
{
alert('This form has already been submitted.'); return false;
}
}
//-->
</script>

In VB.Net Attach it to your button like so:

SubmitButton.Attributes.Add("onClick", "javascript: return
disableSubmit();")
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Nedu N" <ne****@hotmail.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Hi,

I want to have confirmation(Yes/No) on a button of the webform in which
there are many validation controls. I want all the validation controls to be triggered first and then Yes/No confirmation message. By adding just an
confirm attribute for 'onclick' event of the button doesn't work with
validation controls. Is there any short way to go around this.

Thanks
Nedu

Nov 18 '05 #2
Hi Nedu,

Thank you to Justin. I also found a control that may help you. I found it
via the Control Gallery at www.asp.net, under "Form Controls". It's listed
as "Confirmed Buttons". This control takes care of the javascript for you.
The direct link is
http://authors.aspalliance.com/asmit...edbuttons.aspx

You can also learn, in depth, about the interactions of the validation
controls with the button click event at
http://authors.aspalliance.com/kenc/faq6.aspx
My favorite solution from this article is attachEvent.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computerís security.

This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
Reply-To: "S. Justin Gengo" <sj*****@aboutfortunate.com>
From: "S. Justin Gengo" <sj*****@aboutfortunate.com>
References: <uX**************@TK2MSFTNGP12.phx.gbl>
Subject: Re: YES/NO confirmation + Validation control
Date: Tue, 25 Nov 2003 11:31:16 -0600
Lines: 88
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <ey**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 63.238.248.99
Path: cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.phx.gbl!TK2MSFTNGP08
..phx.gbl!TK2MSFTNGP11.phx.gbl Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:192675
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Nedu,

I created a disable submit javascript that keeps a user from clicking the
submit button a second time.

The part of the script that will interest you is that I'm tying in to the
.Net validation script in order to check that the submit button doesn't get disabled when the page isn't valid.

I think you could modify it to do what you need.

Here's the script (I've placed a comment line in the "checkSubmit" function in the script where I think you could add your alert):

<script language="javascript">
<!--
var submitcount=0;

function disableSubmit()
{
if (typeof(Page_ClientValidate)=='function')
{
if (Page_ClientValidate() == true)
{
return checkSubmit();
}
else
{
return true;
}
}
else
{
return checkSubmit();
}
}

function checkSubmit()
{
if (submitcount == 0)
{
submitcount++; return true; //You could add your alert here.
}
else
{
alert('This form has already been submitted.'); return false;
}
}
//-->
</script>

In VB.Net Attach it to your button like so:

SubmitButton.Attributes.Add("onClick", "javascript: return
disableSubmit();")
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Nedu N" <ne****@hotmail.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Hi,

I want to have confirmation(Yes/No) on a button of the webform in which
there are many validation controls. I want all the validation controls
to be
triggered first and then Yes/No confirmation message. By adding just an
confirm attribute for 'onclick' event of the button doesn't work with
validation controls. Is there any short way to go around this.

Thanks
Nedu



Nov 18 '05 #3
Mike,

That's a great article. It's got me thinking about converting my code (which
I have in a javascript object I drop on a page and then use to hook up
"regular" .Net buttons to my script) into an inherited button control.

The only problem with the sample you pointed Nedu to is that he specifically
said that he wants his confirmation to fire after the validation and the
sample fires it before the validation.

An excerpt from the article:

"...and I also wanted to be sure my click handler fired first."

And Nedu's request:

"I want all the validation controls to be triggered first and then
Yes/No confirmation message"

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
""Mike Moore [MSFT]"" <mi****@online.microsoft.com> wrote in message
news:sf****************@cpmsftngxa07.phx.gbl...
Hi Nedu,

Thank you to Justin. I also found a control that may help you. I found it
via the Control Gallery at www.asp.net, under "Form Controls". It's listed
as "Confirmed Buttons". This control takes care of the javascript for you.
The direct link is
http://authors.aspalliance.com/asmit...edbuttons.aspx

You can also learn, in depth, about the interactions of the validation
controls with the button click event at
http://authors.aspalliance.com/kenc/faq6.aspx
My favorite solution from this article is attachEvent.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward steps listed to improve your computer's security.

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
Reply-To: "S. Justin Gengo" <sj*****@aboutfortunate.com>
From: "S. Justin Gengo" <sj*****@aboutfortunate.com>
References: <uX**************@TK2MSFTNGP12.phx.gbl>
Subject: Re: YES/NO confirmation + Validation control
Date: Tue, 25 Nov 2003 11:31:16 -0600
Lines: 88
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <ey**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 63.238.248.99
Path:

cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.phx.gbl!TK2MSFTNGP08 phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:192675 X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Nedu,

I created a disable submit javascript that keeps a user from clicking the submit button a second time.

The part of the script that will interest you is that I'm tying in to the .Net validation script in order to check that the submit button doesn't

get
disabled when the page isn't valid.

I think you could modify it to do what you need.

Here's the script (I've placed a comment line in the "checkSubmit"

function
in the script where I think you could add your alert):

<script language="javascript">
<!--
var submitcount=0;

function disableSubmit()
{
if (typeof(Page_ClientValidate)=='function')
{
if (Page_ClientValidate() == true)
{
return checkSubmit();
}
else
{
return true;
}
}
else
{
return checkSubmit();
}
}

function checkSubmit()
{
if (submitcount == 0)
{
submitcount++; return true; //You could add your alert here.
}
else
{
alert('This form has already been submitted.'); return false;
}
}
//-->
</script>

In VB.Net Attach it to your button like so:

SubmitButton.Attributes.Add("onClick", "javascript: return
disableSubmit();")
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Nedu N" <ne****@hotmail.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Hi,

I want to have confirmation(Yes/No) on a button of the webform in which there are many validation controls. I want all the validation controls

to
be
triggered first and then Yes/No confirmation message. By adding just an confirm attribute for 'onclick' event of the button doesn't work with
validation controls. Is there any short way to go around this.

Thanks
Nedu


Nov 18 '05 #4
Thank you Mike..
Sue..i will look into this article...

""Mike Moore [MSFT]"" <mi****@online.microsoft.com> wrote in message
news:sf****************@cpmsftngxa07.phx.gbl...
Hi Nedu,

Thank you to Justin. I also found a control that may help you. I found it
via the Control Gallery at www.asp.net, under "Form Controls". It's listed
as "Confirmed Buttons". This control takes care of the javascript for you.
The direct link is
http://authors.aspalliance.com/asmit...edbuttons.aspx

You can also learn, in depth, about the interactions of the validation
controls with the button click event at
http://authors.aspalliance.com/kenc/faq6.aspx
My favorite solution from this article is attachEvent.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward steps listed to improve your computer's security.

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
Reply-To: "S. Justin Gengo" <sj*****@aboutfortunate.com>
From: "S. Justin Gengo" <sj*****@aboutfortunate.com>
References: <uX**************@TK2MSFTNGP12.phx.gbl>
Subject: Re: YES/NO confirmation + Validation control
Date: Tue, 25 Nov 2003 11:31:16 -0600
Lines: 88
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <ey**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 63.238.248.99
Path:

cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.phx.gbl!TK2MSFTNGP08 phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:192675 X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Nedu,

I created a disable submit javascript that keeps a user from clicking the submit button a second time.

The part of the script that will interest you is that I'm tying in to the .Net validation script in order to check that the submit button doesn't

get
disabled when the page isn't valid.

I think you could modify it to do what you need.

Here's the script (I've placed a comment line in the "checkSubmit"

function
in the script where I think you could add your alert):

<script language="javascript">
<!--
var submitcount=0;

function disableSubmit()
{
if (typeof(Page_ClientValidate)=='function')
{
if (Page_ClientValidate() == true)
{
return checkSubmit();
}
else
{
return true;
}
}
else
{
return checkSubmit();
}
}

function checkSubmit()
{
if (submitcount == 0)
{
submitcount++; return true; //You could add your alert here.
}
else
{
alert('This form has already been submitted.'); return false;
}
}
//-->
</script>

In VB.Net Attach it to your button like so:

SubmitButton.Attributes.Add("onClick", "javascript: return
disableSubmit();")
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Nedu N" <ne****@hotmail.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Hi,

I want to have confirmation(Yes/No) on a button of the webform in which there are many validation controls. I want all the validation controls

to
be
triggered first and then Yes/No confirmation message. By adding just an confirm attribute for 'onclick' event of the button doesn't work with
validation controls. Is there any short way to go around this.

Thanks
Nedu


Nov 18 '05 #5
Thank you Justin...
It works great...

"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:eJ*************@TK2MSFTNGP10.phx.gbl...
Mike,

That's a great article. It's got me thinking about converting my code (which I have in a javascript object I drop on a page and then use to hook up
"regular" .Net buttons to my script) into an inherited button control.

The only problem with the sample you pointed Nedu to is that he specifically said that he wants his confirmation to fire after the validation and the
sample fires it before the validation.

An excerpt from the article:

"...and I also wanted to be sure my click handler fired first."

And Nedu's request:

"I want all the validation controls to be triggered first and then
Yes/No confirmation message"

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
""Mike Moore [MSFT]"" <mi****@online.microsoft.com> wrote in message
news:sf****************@cpmsftngxa07.phx.gbl...
Hi Nedu,

Thank you to Justin. I also found a control that may help you. I found it
via the Control Gallery at www.asp.net, under "Form Controls". It's listed as "Confirmed Buttons". This control takes care of the javascript for you. The direct link is
http://authors.aspalliance.com/asmit...edbuttons.aspx

You can also learn, in depth, about the interactions of the validation
controls with the button click event at
http://authors.aspalliance.com/kenc/faq6.aspx
My favorite solution from this article is attachEvent.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three

straightforward
steps listed to improve your computer's security.

This posting is provided "AS IS", with no warranties, and confers no

rights.


--------------------
Reply-To: "S. Justin Gengo" <sj*****@aboutfortunate.com>
From: "S. Justin Gengo" <sj*****@aboutfortunate.com>
References: <uX**************@TK2MSFTNGP12.phx.gbl>
Subject: Re: YES/NO confirmation + Validation control
Date: Tue, 25 Nov 2003 11:31:16 -0600
Lines: 88
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <ey**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 63.238.248.99
Path:

cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.phx.gbl!TK2MSFTNGP08
phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:192675 X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Nedu,

I created a disable submit javascript that keeps a user from clicking the submit button a second time.

The part of the script that will interest you is that I'm tying in to the .Net validation script in order to check that the submit button doesn't get
disabled when the page isn't valid.

I think you could modify it to do what you need.

Here's the script (I've placed a comment line in the "checkSubmit"

function
in the script where I think you could add your alert):

<script language="javascript">
<!--
var submitcount=0;

function disableSubmit()
{
if (typeof(Page_ClientValidate)=='function')
{
if (Page_ClientValidate() == true)
{
return checkSubmit();
}
else
{
return true;
}
}
else
{
return checkSubmit();
}
}

function checkSubmit()
{
if (submitcount == 0)
{
submitcount++; return true; //You could add your alert here.
}
else
{
alert('This form has already been submitted.'); return false;
}
}
//-->
</script>

In VB.Net Attach it to your button like so:

SubmitButton.Attributes.Add("onClick", "javascript: return
disableSubmit();")
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Nedu N" <ne****@hotmail.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> I want to have confirmation(Yes/No) on a button of the webform in which > there are many validation controls. I want all the validation
controls
to
be
> triggered first and then Yes/No confirmation message. By adding just

an > confirm attribute for 'onclick' event of the button doesn't work

with > validation controls. Is there any short way to go around this.
>
> Thanks
> Nedu
>
>
>


Nov 18 '05 #6
Nedu,

Great! I think I'll have to add a version like this to my javascript
component.

Until your request I never thought of combining the two pieces of code [a
javascript confirmation and disable submit], but it makes perfect sense.

Thanks for the idea!

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Nedu N" <ne****@hotmail.com> wrote in message
news:eQ*************@TK2MSFTNGP10.phx.gbl...
Thank you Justin...
It works great...

"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:eJ*************@TK2MSFTNGP10.phx.gbl...
Mike,

That's a great article. It's got me thinking about converting my code

(which
I have in a javascript object I drop on a page and then use to hook up
"regular" .Net buttons to my script) into an inherited button control.

The only problem with the sample you pointed Nedu to is that he

specifically
said that he wants his confirmation to fire after the validation and the
sample fires it before the validation.

An excerpt from the article:

"...and I also wanted to be sure my click handler fired first."

And Nedu's request:

"I want all the validation controls to be triggered first and then
Yes/No confirmation message"

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
""Mike Moore [MSFT]"" <mi****@online.microsoft.com> wrote in message
news:sf****************@cpmsftngxa07.phx.gbl...
Hi Nedu,

Thank you to Justin. I also found a control that may help you. I found it via the Control Gallery at www.asp.net, under "Form Controls". It's listed as "Confirmed Buttons". This control takes care of the javascript for you. The direct link is
http://authors.aspalliance.com/asmit...edbuttons.aspx

You can also learn, in depth, about the interactions of the validation
controls with the button click event at
http://authors.aspalliance.com/kenc/faq6.aspx
My favorite solution from this article is attachEvent.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the http://www.microsoft.com/protect site and perform the three

straightforward
steps listed to improve your computer's security.

This posting is provided "AS IS", with no warranties, and confers no

rights.


--------------------
> Reply-To: "S. Justin Gengo" <sj*****@aboutfortunate.com>
> From: "S. Justin Gengo" <sj*****@aboutfortunate.com>
> References: <uX**************@TK2MSFTNGP12.phx.gbl>
> Subject: Re: YES/NO confirmation + Validation control
> Date: Tue, 25 Nov 2003 11:31:16 -0600
> Lines: 88
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> Message-ID: <ey**************@TK2MSFTNGP11.phx.gbl>
> Newsgroups: microsoft.public.dotnet.framework.aspnet
> NNTP-Posting-Host: 63.238.248.99
> Path:

cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.phx.gbl!TK2MSFTNGP08
phx.gbl!TK2MSFTNGP11.phx.gbl
> Xref: cpmsftngxa07.phx.gbl

microsoft.public.dotnet.framework.aspnet:192675
> X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
> Nedu,
>
> I created a disable submit javascript that keeps a user from
clicking
the
> submit button a second time.
>
> The part of the script that will interest you is that I'm tying in
to the
> .Net validation script in order to check that the submit button doesn't get
> disabled when the page isn't valid.
>
> I think you could modify it to do what you need.
>
> Here's the script (I've placed a comment line in the "checkSubmit"
function
> in the script where I think you could add your alert):
>
> <script language="javascript">
> <!--
> var submitcount=0;
>
> function disableSubmit()
> {
> if (typeof(Page_ClientValidate)=='function')
> {
> if (Page_ClientValidate() == true)
> {
> return checkSubmit();
> }
> else
> {
> return true;
> }
> }
> else
> {
> return checkSubmit();
> }
> }
>
> function checkSubmit()
> {
> if (submitcount == 0)
> {
> submitcount++; return true; //You could add your alert here.
> }
> else
> {
> alert('This form has already been submitted.'); return false;
> }
> }
> //-->
> </script>
>
> In VB.Net Attach it to your button like so:
>
> SubmitButton.Attributes.Add("onClick", "javascript: return
> disableSubmit();")
>
>
> --
> Sincerely,
>
> S. Justin Gengo, MCP
> Web Developer / Programmer
>
> Free code library at:
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzche
>
>
> "Nedu N" <ne****@hotmail.com> wrote in message
> news:uX**************@TK2MSFTNGP12.phx.gbl...
> > Hi,
> >
> > I want to have confirmation(Yes/No) on a button of the webform in

which
> > there are many validation controls. I want all the validation controls to
> be
> > triggered first and then Yes/No confirmation message. By adding
just an
> > confirm attribute for 'onclick' event of the button doesn't work

with > > validation controls. Is there any short way to go around this.
> >
> > Thanks
> > Nedu
> >
> >
> >
>
>
>



Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Tim Meagher | last post: by
2 posts views Thread by Tim Frawley | last post: by
2 posts views Thread by simon_eyer | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.