473,890 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:RequiredFi eldValidator ID="valText" ControlToValida te="txtTest"
Runat="server" Text="*" Display="Dynami c" ErrorMessage="E nter Value" />
<asp:Validation Summary DisplayMode="Bu lletList" Runat="server"/>
<asp:Button Text="Submit" ID="Submit" Runat="server"/>
</form>

<script language="javas cript">
<!--
function ValidateForm(ta rgetForm)
{
return(confirm( 'Are you sure?'));
}
-->
</script>

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

this.Submit.Att rbutes.Add("onc lick", "javascript:ret urn
ValidateForm(th is.form);");

I have NOT turned off client side validation / scripting.

Now, when I run the page and click on the submit button, the
ValidationSumma ry 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.At trbutes.Add.." call from the code behind
file, the ValidationSumma ry control gets updated without making a trip to
the server.
How do I make the ValidationSumma ry 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 1876
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="javas cript">
<!--
function ValidateForm(ta rgetForm)
{
if(Page_ClientV alidate())
{
return(confirm( 'Are you sure?'));
}
}
-->
</script>

The Page_ClientVali date 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 ValidationSumma ry control updated.

regards
CGUY

"CGuy" <cg**@csharp.ne t> wrote in message
news:uM******** ******@TK2MSFTN GP12.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:RequiredFi eldValidator ID="valText" ControlToValida te="txtTest"
Runat="server" Text="*" Display="Dynami c" ErrorMessage="E nter Value" />
<asp:Validation Summary DisplayMode="Bu lletList" Runat="server"/>
<asp:Button Text="Submit" ID="Submit" Runat="server"/>
</form>

<script language="javas cript">
<!--
function ValidateForm(ta rgetForm)
{
return(confirm( 'Are you sure?'));
}
-->
</script>

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

this.Submit.Att rbutes.Add("onc lick", "javascript:ret urn
ValidateForm(th is.form);");

I have NOT turned off client side validation / scripting.

Now, when I run the page and click on the submit button, the
ValidationSumma ry 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.At trbutes.Add.." call from the code behind
file, the ValidationSumma ry control gets updated without making a trip to
the server.
How do I make the ValidationSumma ry 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
1020
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 selecting an item from a drop down list to get an id, or by entering the id manually). I want to force the user to enter one or the other and currently have Validation on the two controls. My problem is that I want to be able to move between the two controls without causing the validation. I thought...
0
1402
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 having a problem with the validation. On page one (which is actually just a Panel control), when the user clicks "next," I hide Panel_1 and show Panel_2. However, the RequiredFieldValidator controls in Panel_1 only appear to work with Internet Explorer on Windows; when I click "next" using...
0
1382
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 second problem. I have created a class called BasePage that inherits from System.Web.UI.Page so that I can implement a "template" for all pages in an app. My BasePage class is in a class library project and there is also a web app in the same solution that has a project reference back to the...
3
2835
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: i have many webforms in a site, most with two different custom controls, one is a login module, the other is a generic data entry module. When there are no validation controls on the page there is no problem. But when the the data entry module has validation controls, the login module triggers...
6
1399
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 application to the live production environment, using VS .NET's "Copy Project" feature, which copys only the files necessary to run on another machine, the validation controls simply disappear. For example, when i click SUBMIT to submit a form that's empty, the validation controls don't do...
5
2059
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 should not cause validation but they have no design time property of causevalidation. How can I keep them from causing validation? Thanks, T
2
6717
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. The message box will display the text in the textbox from the Validating event. Now put the focus back on the textbox click the button bar button. Nothing happens. The form causes validation is true, so is the button bar and the control.
1
1893
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 errors occur on the page. Background: My page contains a radio control which the user must answer to finish the page entry. If user hits submit button without selecting item from control, summary validation error displays. In this case one click is sufficient. Once the user selects choice on...
0
2144
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 errors occur on the page. Background: My page contains a radio control which the user must answer to finish the page entry. If user hits submit button without selecting item from control, summary validation error displays. In this case one click is sufficient. Once the user selects choice on...
5
5808
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 (ASP.NET 2.0) and deployed it on the Client's Server. Apparently, we have used a lot of ASP Validation Controls in our pages all
0
9819
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10918
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9625
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8015
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7169
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4674
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4270
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.