Solved

postback fires error msg from other sub procedure

Posted on 2007-03-18
3
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

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…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

615 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