Wrox Programmer Forums
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 30th, 2010, 02:25 AM
Authorized User
Join Date: Jan 2010
Posts: 34
Thanks: 5
Thanked 0 Times in 0 Posts
Default validation group Question

Hi Imar
I have a question about validation group behaviour:
I have a form with 2 divs
each div has textbox, button and Validator on the textbox.
each has its own validation group and validation summary.
here is the code:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <form id="form1" runat="server">
    <asp:TextBox Width="90px" ID="txtSearch" runat="server" Font-Size="12px" />
    <asp:Button ID="cmdSearch" runat="server" ValidationGroup="SearchInfo" Text="Go"/>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Enter Search Text"
      ValidationGroup="SearchInfo" Display="None" ControlToValidate="txtSearch" SetFocusOnError="True" />
    Qty:<asp:TextBox ID="txtQty" Width="35px" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" ValidationGroup="ItemsInfo" Text="Check Qty"/>
    <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="txtQty"
      Type="Integer" Operator="DataTypeCheck" ValidationGroup="ItemsInfo" Display="None"
      ErrorMessage="Enter numeric value" SetFocusOnError="True" />
  <asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="SingleParagraph"
    ShowMessageBox="true" ShowSummary="false" ValidationGroup="SearchInfo" />
  <asp:ValidationSummary ID="ValidationSummary2" runat="server" DisplayMode="BulletList"
    ShowMessageBox="true" ShowSummary="false" ValidationGroup="ItemsInfo" />
every thing work ok, but when the focus is on the txtQty texbox and I press "Enter" Key on the keyboard the message of the search text is poping?

why is that and how it can be avoided?

Old November 30th, 2010, 03:57 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

The Enter behavior isn't influenced by validation groups. What you're looking for instead is the DefaultButton on a form or Panel: http://msdn.microsoft.com/en-us/libr...ultbutton.aspx

For questions not directly related to my book, would you mind posting in a more generic ASP.NET category here: http://p2p.wrox.com/asp-net-3-5-436/? Makes it easier for everyone to participate and find the stuff they are looking for.


Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!

Similar Threads
Thread Thread Starter Forum Replies Last Post
About a question with validation nealwang1019 XML 7 May 7th, 2009 03:52 PM
About a question with validation nealwang1019 BOOK: Beginning XML, 4th Ed ISBN: 978-0-470-11487-2 0 May 4th, 2009 10:58 AM
Group question Tere Crystal Reports 1 October 19th, 2004 11:08 AM
Group By Question nmccamy Access 1 February 18th, 2004 09:14 AM
GROUP BY and ORDER BY question savoym SQL Language 6 June 24th, 2003 08:24 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.