YES/NO confirmation + Validation control

N

Nedu N

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
 
S

S. Justin Gengo

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
 
M

Mike Moore [MSFT]

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/asmith/articles/confirmedbuttons.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.


--------------------
 
S

S. Justin Gengo

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]" said:
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/asmith/articles/confirmedbuttons.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" <[email protected]>
From: "S. Justin Gengo" <[email protected]>
References: <[email protected]>
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: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 63.238.248.99
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.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


to
 
N

Nedu N

Thank you Justin...
It works great...

S. Justin Gengo said:
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]" said:
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/asmith/articles/confirmedbuttons.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" <[email protected]>
From: "S. Justin Gengo" <[email protected]>
References: <[email protected]>
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: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 63.238.248.99
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
doesn't
get controls
to
 
N

Nedu N

Thank you Mike..
Sue..i will look into this article...

"Mike Moore [MSFT]" said:
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/asmith/articles/confirmedbuttons.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" <[email protected]>
From: "S. Justin Gengo" <[email protected]>
References: <[email protected]>
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: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 63.238.248.99
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.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


to
 
S

S. Justin Gengo

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 said:
Thank you Justin...
It works great...

S. Justin Gengo said:
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]" said:
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/asmith/articles/confirmedbuttons.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" <[email protected]>
From: "S. Justin Gengo" <[email protected]>
References: <[email protected]>
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: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 63.238.248.99
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
clicking
the to
the just
an
 

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,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top