473,757 Members | 5,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ajax with field validator

How do I prevent field validator which resides outside of UpdatePanel
from firing off? The label will update correctly without
RequiredFieldVa lidator via Ajax. TIA.

Code below....

<%@ Page Language="C#" AutoEventWireup ="true"
CodeBehind="Def ault.aspx.cs" Inherits="WebAp plication1._Def ault" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptMana ger ID="ScriptManag er1" runat="server">
</asp:ScriptManag er>

<asp:TextBox ID="TextBox1" runat="server"> </
asp:TextBox><as p:RequiredField Validator
ID="RequiredFie ldValidator1" runat="server"
ErrorMessage="R equired" ControlToValida te="TextBox1">* </
asp:RequiredFie ldValidator>
<asp:UpdatePane l ID="UpdatePanel 1" runat="server">
<ContentTemplat e>
<asp:Label ID="Label1" runat="server" Text="Label"></
asp:Label><br />
<asp:Button ID="Button1"
runat="server" Text="Button" onclick="Button 1_Click1" /
>
</ContentTemplate >
</asp:UpdatePanel >

</div>
</form>
</body>
</html>

--==========
Code behind

protected void Button1_Click1( object sender, EventArgs e)
{
Label1.Text = DateTime.Now.To String();
}
Sep 24 '08 #1
2 1545
You can group the fields via the validationgroup property, although this
doesn't exactly make sense because if you're trying to validate something
then it has to be fired with your button that's inside your updatepanel.
Another possibility is to disable the client-side validation on the
requiredfieldva lidator. This is good form anyways as you should never really
perform client-side validation since the validation script can be
circumvented on the browser.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression

<go*******@gmai l.comwrote in message
news:e8******** *************** ***********@26g 2000hsk.googleg roups.com...
How do I prevent field validator which resides outside of UpdatePanel
from firing off? The label will update correctly without
RequiredFieldVa lidator via Ajax. TIA.

Code below....

<%@ Page Language="C#" AutoEventWireup ="true"
CodeBehind="Def ault.aspx.cs" Inherits="WebAp plication1._Def ault" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptMana ger ID="ScriptManag er1" runat="server">
</asp:ScriptManag er>

<asp:TextBox ID="TextBox1" runat="server"> </
asp:TextBox><as p:RequiredField Validator
ID="RequiredFie ldValidator1" runat="server"
ErrorMessage="R equired" ControlToValida te="TextBox1">* </
asp:RequiredFie ldValidator>
<asp:UpdatePane l ID="UpdatePanel 1" runat="server">
<ContentTemplat e>
<asp:Label ID="Label1" runat="server" Text="Label"></
asp:Label><br />
<asp:Button ID="Button1"
runat="server" Text="Button" onclick="Button 1_Click1" /
>>
</ContentTemplate >
</asp:UpdatePanel >

</div>
</form>
</body>
</html>

--==========
Code behind

protected void Button1_Click1( object sender, EventArgs e)
{
Label1.Text = DateTime.Now.To String();
}
Sep 24 '08 #2
Thanks for replying and sorry for late post.

I resolved it by, like you said, putting and grouping
validationgroup . The sample I gave was for simplicity. My original
requirement was to have two drop down lists and have one fire off and
populate the second one. For example, first one is country and second
is the state. So on selectedindexch anged from first one, second will
populate states based on country selection. Thanks again.
Sep 29 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
683
by: Martin | last post by:
Dear Group It says in MSDN that a field can be associated with more than one validators but can one validator be associated with more than one field? Or do I need a validator for each field? How does it work? Using Handlers? Thanks for your efforts! Martin
0
1192
by: Dhanashree | last post by:
I have a RangeValidator which uses AJAX to call server-side validation function from the client. The code works fine, but I have one problem. following is my range validator class: public class RangeValidator: BaseValidator,ICallbackEventHandler { public event ServerValidateEventHandler ServerValidate; String _controlToValidateValue;
3
3494
by: Sandman | last post by:
So, I've used ajax for quite some time for different stuff. Mostly I just feed a funktion I made with the ID of the DIV that should be updated with the output from page XXX.php Now I want to have a standard funktion to set a JS variabel to the output of a page. I am doing a date validation thing, which is done in PHP. So this is how far I've come so far: function ajaxresults(url){ var ajax = createAjaxObject();
5
3223
by: lucyh3h | last post by:
Hi, I am trying to use XMLHttpRequest to do server side validation. I have several fields on a form and a submit button. The submit button has an event assocated with it when clicked. The javascript method will do the form validation for each field one by one. For each field, an XMLHttpRequst will be made to a PHP file and get the return, either set an error field (<span>'s innerHTML) or leave it empty. Then I'll check the error field...
7
3620
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete Files
2
1746
by: Jeremy | last post by:
How would I go about using a custom validator to make a server side call using ajax?
8
2688
omerbutt
by: omerbutt | last post by:
hi there i have a form with multiple input (type/text ) fields and three inputs(type/file) fields i have to submit the form via ajax because i have multiple forms on this page ,you can say it is a contact_us.php page.Now i can get all the inputs at the other end else the input(type/file) i donot want a submit button what i want that some how io can send the file name and the path of the picture that is to be uploaded and send to a page via ajax...
1
1168
by: Stratum | last post by:
I use ASP.Net Validator controls on some Web pages, specifically, the Required Field Validator which works on the client side before a postback. The page has worked fine for some time. After I added the AJAX Control Toolkit to my VS2005, and modified the Web.config file, the pages with the original ASP.Net validator controls could no longer be accessed.
2
1819
by: Alec MacLean | last post by:
Hi, I have a page using AJAX. The page has three modal popups that work fine when I don't have field validators in place. As soon as I put a validator in place, the popup "form" the validator is part of still works, but the click events (postback) of the other popups is stopped. So, I have two data entry forms I want to validate, each within their own modal Popup panels. The system detects the user type accessing the page and this...
0
9487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9904
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8736
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.