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

psot back

Hi
If anyone can help

Is there away to make javascript prevent a postback on a button,
i have tried putting the button in a <spantag with onclick but it carrys
out the javascript functioon and then posts back even if i use return false;

I want javascript to do clientside valudation before posting back

cheers in advance

Roger

Nov 14 '07 #1
2 920
"Roger" <ro********@btinternet.comwrote in message
news:AE**********************************@microsof t.com...
Is there away to make javascript prevent a postback on a button,
i have tried putting the button in a <spantag with onclick but it carrys
out the javascript functioon and then posts back even if i use return
false;

I want javascript to do clientside valudation before posting back
<script type="text/javascript">
function validateForm()
{
if (...validation condition fails...)
{
alert('Validation failed');
return false;
}
</script>

<asp:Button ID="MyButton" runat="server" Text="Save" OnClick="MyButton_Save"
OnClientClick="return validateForm();" />
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 14 '07 #2
thanks very much simple really :)
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
"Roger" <ro********@btinternet.comwrote in message
news:AE**********************************@microsof t.com...
>Is there away to make javascript prevent a postback on a button,
i have tried putting the button in a <spantag with onclick but it
carrys out the javascript functioon and then posts back even if i use
return false;

I want javascript to do clientside valudation before posting back

<script type="text/javascript">
function validateForm()
{
if (...validation condition fails...)
{
alert('Validation failed');
return false;
}
</script>

<asp:Button ID="MyButton" runat="server" Text="Save"
OnClick="MyButton_Save" OnClientClick="return validateForm();" />
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Nov 14 '07 #3

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

Similar topics

25
by: KK | last post by:
Hi, I am using history.go(-1) for implementing the back button functionality. Its working fine but with this exception. 1. The page which is having back button has some hyperlinks on it. ...
3
by: Alessandro | last post by:
Hi all! I'm trying to write a file transfer application using TCP, but I'm having some problem to connect the client and the server. Sniffing with Ethereal I can see the packets sent from the...
1
by: Peter D. Dunlap | last post by:
Hello, I realize that this may not be the best place to ask this question, through the application is asp.net. I also realize that questions about disabling the back button are generally met...
4
by: Hypo | last post by:
I added a 'Back' button to my page, and wrote 'OnClick' code something like this: Response.Write("<script>history.go(-" + iDepthIndex.ToString() + ");</script>"); But, it dosnt work! Effect...
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
29
by: Tom wilson | last post by:
I can't believe this is such an impossibility... I have an asp.net page. It accepts data through on form fields and includes a submit button. The page loads up and you fill out some stuff. ...
8
by: rdemyan via AccessMonster.com | last post by:
Anyone have any ideas on how to determine when the back-end file (containing only tables) has been updated with new data. The date/time of the file won't work because it gets updated to the...
5
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a...
4
by: bendlam | last post by:
I have a page that contains search criteria and when you click on the search button it causes a post back that populates a dataview on the same page. One of the gridview columns contains a link...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
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...
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
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...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.