473,387 Members | 1,481 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,387 software developers and data experts.

client side script, then server side

i have a server side button which 1st needs to run some client side
script for form checking. I got this working from the attributes
thing.

Then, if all is valid client side, i need to call the server side
function for the button. I can't just do a submit because that won't
call the server function. Anyone know how to do this?
Nov 19 '05 #1
4 1230
> i have a server side button which 1st needs to run some client side
script for form checking. I got this working from the attributes
thing.

Then, if all is valid client side, i need to call the server side
function for the button. I can't just do a submit because that won't
call the server function. Anyone know how to do this?


It sounds like you have a form, and, if the form is valid, you want
something to happen, correct?

If so, in the button click function, you'd do something like this:

page.validate

if page.isvalid then...
do your thing
else
don't do it
end if

-Darrel
Nov 19 '05 #2
You might want to use the built in ASP.NET validation controls, since they
provide this kind of functionality.

If your needs are modest, the code below may get you started:

This server side code uses javascript to display a confirmation message.
myDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")

In this example, the Delete button will post back only if the person
confirms they want to delete. Otherwise your server code is never called in
response to the button click.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Mortar" <a@b.com> wrote in message
news:41***************@nntp.broadband.rogers.com.. .
i have a server side button which 1st needs to run some client side
script for form checking. I got this working from the attributes
thing.

Then, if all is valid client side, i need to call the server side
function for the button. I can't just do a submit because that won't
call the server function. Anyone know how to do this?

Nov 19 '05 #3
> i have a server side button which 1st needs to run some client side
script for form checking. I got this working from the attributes
thing.

Then, if all is valid client side, i need to call the server side
function for the button. I can't just do a submit because that won't
call the server function. Anyone know how to do this?


Assuming your control like so:

<asp:button id="someButton" runat="server" />

add an onclick attribute like: "return isValid();"
(so the output should be <inut type="submit" id="someButton" onclick="return
isValid();" />)

and define a function like:
"function isValid()
{
if(something is valid)
return true;
else
return false;
}"

when you return false from the isValid, the click event is aborted so the
form will not submit. If you return true, the event will continue processing
and the form will be submitted.

Nov 19 '05 #4

awesome! thanks guys.
On Mon, 24 Jan 2005 23:43:55 GMT, a@b.com (Mortar) wrote:
i have a server side button which 1st needs to run some client side
script for form checking. I got this working from the attributes
thing.

Then, if all is valid client side, i need to call the server side
function for the button. I can't just do a submit because that won't
call the server function. Anyone know how to do this?


Nov 19 '05 #5

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

Similar topics

9
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
5
by: tmb | last post by:
Is there a way to use ASP to 'push' a new image to the client every 15 seconds or so? I guess the entire page will have to be 're-sent' to the client but I'm not sure. I'm trying to 'rotate'...
1
by: Jim Hammond | last post by:
I can get data from a client-side assembly to the server in two manual steps, but I need to be able to do it in one step. Step 1: The user presses the manually coded "Step 1" button, which calls...
8
by: Mike Fellows | last post by:
Ok, im not sure if this is at all possible and if it is how i go about it is beyond me i have a piece of client side code that requires a piece of data from the server side (an ID number in this...
1
by: Carl Jones via .NET 247 | last post by:
(Type your message here) I'm trying to run a client-side script from a web page. It's a VB script that gets information (computer name, software versions etc )about the computer and writes it to a...
7
by: Mike Rand | last post by:
I am having a really hard time trying to get some client side code hooked up in VS2005, ASP 2.0. The code is in an .inc file (vbscript). The first problem I am encountering is the ASP.NET page...
3
by: jesper_lofgren | last post by:
Hello, I have a problem, i have a event in asp.net codebehind file that updating a datasource. If that update went well i want to refresh my treeview thats on another page. The script works...
1
by: Chris | last post by:
Hi, I have jsut started to learn ASP development and have read many articles regarding which is the best to use regarding JavaScript or VBScript. All of the learning that I have done so far has...
5
by: Ankur | last post by:
Hi Folks, I am new for this group. I want to clarify one thing what's a basic difference between Client Side Java Script and Server Side Java Script. how we can differentiate it. Why we called...
5
by: Simon | last post by:
I heard that we could do that by using AJAX. Could anybody share how to do it? Thanks.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.