Solved

postback fires error msg from other sub procedure

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 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