472,342 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,342 software developers and data experts.

Problem with validation controls

Hi,

I have the following code in my aspx page

<form id="Form1" method="post" runat="server">
<asp:TextBox ID="txtTest" Runat="server" />
<asp:RequiredFieldValidator ID="valText" ControlToValidate="txtTest"
Runat="server" Text="*" Display="Dynamic" ErrorMessage="Enter Value" />
<asp:ValidationSummary DisplayMode="BulletList" Runat="server"/>
<asp:Button Text="Submit" ID="Submit" Runat="server"/>
</form>

<script language="javascript">
<!--
function ValidateForm(targetForm)
{
return(confirm('Are you sure?'));
}
-->
</script>

In the code behind fiel for the aspx page, i have the following code (to
invoke the "ValidateForm" javascript function when the button is clicked)

this.Submit.Attrbutes.Add("onclick", "javascript:return
ValidateForm(this.form);");

I have NOT turned off client side validation / scripting.

Now, when I run the page and click on the submit button, the
ValidationSummary control is updated only after the form is posted to the
server - it does not happen at the client side (I can see the form is
posted). But, if i remove the javascript funtion call from the Submit button
(by removing the "this.Submit.Attrbutes.Add.." call from the code behind
file, the ValidationSummary control gets updated without making a trip to
the server.
How do I make the ValidationSummary control display the error message(s)
without making a trip to the server when the button has a javascript
function tied to it's client side onclick event handler? Any help will be
greatly appreciated.

CGUY
Nov 17 '05 #1
1 1815
Found out the solution myself. Though I would post it so that it benefits
someone....

Solution - modify the client side javascript function to the following

<script language="javascript">
<!--
function ValidateForm(targetForm)
{
if(Page_ClientValidate())
{
return(confirm('Are you sure?'));
}
}
-->
</script>

The Page_ClientValidate is a javascript validation API that will validate
all the (active) enabled validators in the page - so calling this function
in the above javascript function will result in the validators being
validated and the ValidationSummary control updated.

regards
CGUY

"CGuy" <cg**@csharp.net> wrote in message
news:uM**************@TK2MSFTNGP12.phx.gbl...
Hi,

I have the following code in my aspx page

<form id="Form1" method="post" runat="server">
<asp:TextBox ID="txtTest" Runat="server" />
<asp:RequiredFieldValidator ID="valText" ControlToValidate="txtTest"
Runat="server" Text="*" Display="Dynamic" ErrorMessage="Enter Value" />
<asp:ValidationSummary DisplayMode="BulletList" Runat="server"/>
<asp:Button Text="Submit" ID="Submit" Runat="server"/>
</form>

<script language="javascript">
<!--
function ValidateForm(targetForm)
{
return(confirm('Are you sure?'));
}
-->
</script>

In the code behind fiel for the aspx page, i have the following code (to
invoke the "ValidateForm" javascript function when the button is clicked)

this.Submit.Attrbutes.Add("onclick", "javascript:return
ValidateForm(this.form);");

I have NOT turned off client side validation / scripting.

Now, when I run the page and click on the submit button, the
ValidationSummary control is updated only after the form is posted to the
server - it does not happen at the client side (I can see the form is
posted). But, if i remove the javascript funtion call from the Submit button (by removing the "this.Submit.Attrbutes.Add.." call from the code behind
file, the ValidationSummary control gets updated without making a trip to
the server.
How do I make the ValidationSummary control display the error message(s)
without making a trip to the server when the button has a javascript
function tied to it's client side onclick event handler? Any help will be
greatly appreciated.

CGUY

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve | last post by:
Hello I have several controls on a form linked to a dataset. Two of the controls can be used to populate one field in the dataset (i.e. by...
0
by: Chris Nunciato | last post by:
I'm working on a simple Web application that uses a wizard-style data-entry paradigm (seven "pages", using "next" and "previous" buttons), and I'm...
0
by: Dan | last post by:
I posted a similar post regarding problems with VS.NET design mode. I fixed that problem (with much thanks to this newsgroup) but now I have a...
3
by: john morales | last post by:
Hi guys, I have a problem and i know there must be a solution for this as it is such a basic common practice in asp.net development. Scenario:...
6
by: charliewest | last post by:
In my development environment, the validation controls work fine. (Incidentally, i am using almost all of them). However, when i deploy my ASP.NET...
5
by: Tina | last post by:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing validation elsewhere on the page. I want to specify that these buttons...
2
by: Tim Frawley | last post by:
Source code attached indicates my problem with validation and a button bar save button. Fill the Textbox with some text then tab off the control....
1
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I'm having trouble working with a Summary Validation control. I need to click my submit button twice for the Summary to display when validation...
0
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I'm having trouble working with a Summary Validation control. I need to click my submit button twice for the Summary to display when validation...
5
by: Kuldeep | last post by:
Framework: Visual Studio 2005 Technology: ASP.NET 2.0 Language: C#.NET 2.0 Hi All, We have developed a Web Application on Visual Studio 2005...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.