473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How use javascript with asp.net forms?

I have a problem that sounds simple but seems impossible with asp.net.
I calculate a variable in the Page_Load event, call it X. Then I want
my range validators to fire when a textbox value is greater than X.
They should give an error message, both as a messagebox and inline in
the page. I can't get the range validators to use X. I get syntax
errors when I try. I tried Custom Validators and got the same problem.

So now I want to try using client side javascript with forms. This may
not work either, because I calculate X in page_load, and I don't know
how to communicate X to the javascript. But forget that for now, does
anybody know how to intercept the SUBMIT click of an asp.net form and
use client side javascript validation on it?

Nov 19 '05 #1
3 2673
pass the X in a hidden field, but use Styles to hide the field, otherwise
it wont pass any value. in javascript I guess you can use the events fired
when moving away from the textbox and compare that to the hidden field.
"COHENMARVIN" <co*********@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I have a problem that sounds simple but seems impossible with asp.net.
I calculate a variable in the Page_Load event, call it X. Then I want
my range validators to fire when a textbox value is greater than X.
They should give an error message, both as a messagebox and inline in
the page. I can't get the range validators to use X. I get syntax
errors when I try. I tried Custom Validators and got the same problem.

So now I want to try using client side javascript with forms. This may
not work either, because I calculate X in page_load, and I don't know
how to communicate X to the javascript. But forget that for now, does
anybody know how to intercept the SUBMIT click of an asp.net form and
use client side javascript validation on it?

Nov 19 '05 #2
Your post is a bit cluttered, with 3 problems embedded in it. I'll try
to handle them one by one.

"COHENMARVIN" <co*********@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I have a problem that sounds simple but seems impossible with asp.net.
I calculate a variable in the Page_Load event, call it X. Then I want
my range validators to fire when a textbox value is greater than X.
They should give an error message, both as a messagebox and inline in
the page. I can't get the range validators to use X. I get syntax
errors when I try. I tried Custom Validators and got the same problem.
Syntax error means you've typed in something which does not represent a
valud ASP.NET program. If you posted some source code, someone might be able
to find the syntax error and help you out with that.

So now I want to try using client side javascript with forms. This may
not work either, because I calculate X in page_load, and I don't know
how to communicate X to the javascript.
You could output X as a hidden form input, e.g.:

<INPUT TYPE="hidden" VALUE="[whatever the value of X is]">
But forget that for now, does
anybody know how to intercept the SUBMIT click of an asp.net form and
use client side javascript validation on it?


I don't know of a clean way of doing this. It's possible, but would
require lots of messy hacks, so you'd probably be better off with tackling
one of the above two problems first.

- Oliver
Nov 19 '05 #3
I agree with Oliver, who suggests continuing to try to use the validators.
There is no reason why you cannot get a CustomValidator to handle what you
want.

When you state you are calculating a value on the server side and using it
with a RangeValidator, are you using that value as the Minimum or Maximum of
the range? If so, there is no javascript involved. You convert the number to
a string and assign it to one of those properties. The RangeValidator
handles it from there. Just make sure RangeValidator.Type is Integer,
Decimal, or Currency.

Actually I notice that you want the textbox value greater than X. So lets
switch from RangeValidator to CompareValidator. Set the Operator to
GreaterThan and ValueToCompare to the string of the number you calculate.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"COHENMARVIN" <co*********@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I have a problem that sounds simple but seems impossible with asp.net.
I calculate a variable in the Page_Load event, call it X. Then I want
my range validators to fire when a textbox value is greater than X.
They should give an error message, both as a messagebox and inline in
the page. I can't get the range validators to use X. I get syntax
errors when I try. I tried Custom Validators and got the same problem.

So now I want to try using client side javascript with forms. This may
not work either, because I calculate X in page_load, and I don't know
how to communicate X to the javascript. But forget that for now, does
anybody know how to intercept the SUBMIT click of an asp.net form and
use client side javascript validation on it?

Nov 19 '05 #4

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

Similar topics

0
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass...
3
by: bhanubalaji | last post by:
hi, I am unable to disable the text(label) in javascript..it's working fine with IE,but i am using MOZILLA.. can any one help regarding this.. What's the wrong with my code? I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...

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.