Solved

postback fires error msg from other sub procedure

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now