Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 July 16th, 2003, 10:05 AM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.NET bug with online form validation

Scenario:

You have form validation on a textbox called "SearchString" for the form id "blah".

Form id "blah2", which is on the same page, also has a textbox called "SearchString", because they basically submit to the same page (for our purposes, these two forms need to co-exist).

If you enter data into form ID "blah"'s SearchString textbox and hit SUBMIT, ASP.NET's form validation kicks in and tells you that you need to complete the form.

WHY? Because it is erroneously regarding two textboxes from two different forms as being the same textbox.

Why can't it differentiate between blah.SearchString vs. blah2.SearchString?
 
Old July 16th, 2003, 11:30 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

The thing is, ASP.NET is build around the concept of one single form. This means it considers all unique controls (with an ID attribute) as part of the entire form.

To solve this problem you can disable the validations off the controls on the form you are not submitting.

For a good start on this subject, check here:

http://www.aspalliance.com/kenc/faq6.aspx

HtH

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old July 16th, 2003, 09:27 PM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks...if this is by design then I can't help but regard it as counter-intuitive. It is not realistic to expect a page to only ever have one form. I suppose I can disable the validation, but then I'd have zero validation for either form which, again, seems counter-intuitive.

I find it puzzling that in the straight HTML world, values from form id "A" are differentiated from form id "B" with no problem. But now with asp.net, it seems to ignore the form id altogether, lumping two textboxes that come from two different (and more importantly, independently named and id'd) forms as being the same textbox just because they share the same name.

Unless I'm missing something, the object-oriented world should have no problem differentiating between myFormOne.SearchString vs. myFormTwo.SearchString.
 
Old July 17th, 2003, 01:04 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

This is not quite true. You can disable each individual control with client side code. So, in the btnSendForm1_onclick() method (for example) you can disable the validation for form 2 and vice versa.

Hth

Imar


Quote:
quote:[i]I suppose I can disable the validation, but then I'd have zero validation for either form which, again, seems counter-intuitive.
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old July 19th, 2003, 12:34 AM
Authorized User
 
Join Date: Jun 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to kashif Send a message via MSN to kashif Send a message via Yahoo to kashif
Default

cacklebunny..!
we have the more then one form on the same page and what is the problem declaring them coz they have their separate ID and a very good thing in ASP.NET that you can code down the button click events of the form control(button).

PEACE





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create an online test using asp.net and C# Alaphat ASP.NET 2.0 Professional 3 April 14th, 2014 06:16 AM
Validation\Postback bug TheNinthPlayer ASP.NET 3.5 Basics 1 June 6th, 2008 01:00 AM
Bug or no to bug learning C using VS.Net to compil tesh All Other Wrox Books 0 February 14th, 2007 01:06 PM
Online editing in asp.net bneeraj General .NET 0 February 3rd, 2005 09:32 AM
asp.net form validation ashutoshmars .NET Web Services 1 August 17th, 2003 07:58 PM





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