473,545 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run client side javascript with Validation Control

I need to find a way to either

1. run and check all Validation controls (in my case one
CompareValidato r) and run client side javascript function. In this
case I'll use <asp:Button>. So if all validation passes, run custom
javascript. Or.
2. from my client side javascript to run Validation check and then
perform remaining client side function. So in this case I'll use
<input type="button">.

So far, challenge in case 1 is how to capture validation failure and
limit and stop further client side code execution. I had this code.

Button_Search.A ttributes.Add(" onclick",
Page.ClientScri pt.GetPostBackE ventReference(B utton_Search, "") +
";Search(); ");

where Search() is my client side function, which gets executed with
failed client side validation.

In case 2, I would like to do something like... (I'm doing this with
RegisterClientS criptBlock)

function Search()
{
window.top._som evalue = 'xyz';
if (whateverclient validationfucti oniscalled()) // client side
validation function name generated by ASP.NET
window.top.hide PopWin();
}

<input type="button" onclick="Search ();">

Any help appreciated.
Oct 21 '08 #1
2 3830
I think you are trying to do what I do. Here is what I do:

In the code-behind:

// Add Submit Confirmation
btnSubmit.Attri butes.Add("onCl ick", "return ConfirmSubmit() ;");

Then in your aspx page within script tags:

function errorArgs()
{
this.IsValid = true;
this.errorMsg = "";
}

function ConfirmSubmit()
{
var IsValid = true;
var display = "";
var err = new errorArgs();

VerifyVacationD ays(err); // Create your validation code in here.

// I have multiple validation routines that I call, but I put it
down to 1 for ease of reading

if (err.IsValid)
{
return confirm('Are you sure you want to Submit?');
}
else
{
alert(err.error Msg);
return false;
}
}

The key is the "return" in the buttons OnClick event. If it sees
false it will not post back. If it sees true it will.
Oct 21 '08 #2
Thanks for quick response.

So looks like you are calling your own validation functions. I would
like to utilize already generated server-side validation. I just
found my own answer just after posting.

http://forums.asp.net/t/1318892.aspx

With case 2, where...

if (Page_ClientVal idate('SearchVa lidation')) // that was the function
name I was looking for. SearchValidatio n is the ValidationGroup name.
window.top.hide PopWin();

and used in server side....

<asp:Button ID="Button_Sear ch" runat="server" Text="Search"
ValidationGroup ="SearchValidat ion" OnClientClick=" Search();" />

I'm not sure <asp:Buttonis completely necessary or not here but I'll
move on. Thanks again.
Oct 21 '08 #3

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

Similar topics

4
2356
by: | last post by:
Hello Guys, I am using the validation controls to validate my data. But the problem is "The page is still being posted to server". I want to get rid of the round trips to server. Are there any get arounds for this problem apart from the traditional JavaScript?
14
6275
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2) show the error message next to the control. For example, if the text field is empty with RequiredField Validator control, it can show the value in...
3
13118
by: Earl Teigrob | last post by:
I wanted my "Terms and Conditions" Checkbox control to participate in my ASP.NET validation just like all the the other controls on the page. After some time of searching the web for an example of how to do this, I created the script to do it and thought I would share it. Its a littel messy but does the job. If anyone has a better solution,...
3
2183
by: Lisa Calla | last post by:
Hi, I've been struggling with this for a few days. I've seen bits and pieces (how to set up custom validation), but I can't seem to understand how to get client side validation for my custom composite control (the textbox part). I've done a ton of vbnet, am new to aspnet, but barely know how to spell java. Anyone know of a good website or...
1
2499
by: vidya | last post by:
Hi, I have a button which is a web control. I have some validation in javascript for the button in .aspx file and some in the button onclick event in code behind(C#). I need to get through both the java script validation as well as the click in code behind? How can this be done ? Can I call the code behind from the javascript function? If...
3
2953
by: Guadala Harry | last post by:
I hope this is something I can solve without contacting the vendor: I'm implementing a 3rd party component that will, by itself, initiate a PostBack. Apparently it does not support the CausesValidation property - so forms get posted back without any client-side validation. I know I can do validation server side (and do anyway just as a good...
1
3925
by: Hong Hao | last post by:
Recently, I was trying to modify an existing aspx page when client-side validation on that page stopped working. I searched this group and the web in general and found that other people have had the same issue. However, none of the suggested fixes solved my particular problem. I tracked down the cause of the problem, which is related to aspx...
3
8906
by: David Davis | last post by:
I cannot get a web user control to validation client-side using a required field validator. It only validates server side. I have a web user control in .net 2.0. I have a single text box on it. I have a public Text property defined below: <ValidationProperty("Text")> _ Partial Class MyWebUserControl Inherits System.Web.UI.UserControl
2
1654
by: IfThenElse | last post by:
Hello, I am wondering how can I Override/Append to the Client Side JavaScript of a System.Web.UI.WebControls.RequiredFieldValidator Control. I actually need to only add few lines of JavaScript to the Microsoft Supplied JavaScript Function. So I need to Just extend it to do one or two extra things for me.
0
7499
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...
0
7432
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...
0
7689
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7943
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...
0
7786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6022
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...
0
5076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.