Solved

postback fires error msg from other sub procedure

Posted on 2007-03-18
3
246 Views
Last Modified: 2013-11-07
Hi, I have a page where a user can search for a name/address from an id_number entered in a txtbox, the user can also search for a user id_number from inputting user name and adress into different txtbox.

When I tried validating these controls using required field validators I struck a problem.
if the user enters data into one txtbox and hits the submit key for that search the error msg for the other
search function fires.

I realise why this happens. But how can I get around it?

Using asp.net 2.0
0
Comment
Question by:deNZity
3 Comments
 
LVL 6

Expert Comment

by:sara110
ID: 18746275
one method is validating your data client side by javascript and also use code in each button for serverside and not use regular validation, because these validations is just good when you have one button in your page and you won't postback your page twice.
0
 
LVL 6

Expert Comment

by:Niraj_Singh
ID: 18746494
hi,
 i would suggest you to use the validations in code behind. more over your search page would rquire to give a general search result if no specification was provided by the user.
 when user selects or provides some search conditions then you can filter your general search query and give filtered result.
 
0
 
LVL 2

Accepted Solution

by:
uaexpert earned 500 total points
ID: 18746797
You can simply do server side validation as suggested above.
If you want to use client side validation you need to remove your current validators for those text boxes, place one CustomValidator instead and write a small client script which perfoms necessary validation.
In that CustomValidator you will need to set the name of validation function in ClientValidationFunction property. See an example of such function below:
<script type="text/javascript">
<!--
function ClientValidation(source, arguments) {
    var TextBox1 = document.getElementById("TextBox1");
    var TextBox2 = document.getElementById("TextBox2");
    s1 = TextBox1.value; s2 = TextBox2.value;
    if (s1 == "" && s2 == "")
        arguments.IsValid = false;
    else
        arguments.IsValid = true;    
}
-->        
</script>

This script section you can place at the botton of your .aspx file (after closing </html> tag).

By the way if your page is designed to perform some search in a database I can suggest you a special tool for this task: EasyQuery.NET WebForms. See http://devtools.korzh.com/eq/dotnet/ 
This page contains a link to special sample page which demonstrates how EasyQuery.NET controls work.
This tool is free for ASP.NET if you agree to leave special watermark  ("Easy Query') on control's background and "powered by..." link on EasyQuery.NET web page.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question