Solved

postback fires error msg from other sub procedure

Posted on 2007-03-18
3
248 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

680 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