Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 30th, 2010, 02:25 AM
Authorized User
Points: 154, Level: 3
Points: 154, Level: 3 Points: 154, Level: 3 Points: 154, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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:

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">
  <title></title>
</head>
<body>
  <form id="form1" runat="server">
  <div>
    Search:
    <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" />
  </div>
  <div>
    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" />
  </div>
  <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" />
  </form>
</body>
</html>
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?

TIA
BARAK
Reply With Quote
  #2 (permalink)  
Old November 30th, 2010, 03:57 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:22 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.