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

Postback thru javascript

I have asp button control on the page. I need to check some condition
before I postback the page.

Actually it is posting back for both true, false conditions.

I want to postback only if the condition is true. otherwise I want to
stay on the same page.

Note: I have many other asp buttons controls should postback. I need to
check for the condition only for one asp button control.

Thanks.

Nov 29 '06 #1
2 1157
Handle the client-side onclick event. Make the javascript event handler to
return true if you want to proceed with the postback or false otherwise:

myButton.Attributes["onclick"] = "return myJavascriptHandler()";

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
<kr*********@gmail.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
>I have asp button control on the page. I need to check some condition
before I postback the page.

Actually it is posting back for both true, false conditions.

I want to postback only if the condition is true. otherwise I want to
stay on the same page.

Note: I have many other asp buttons controls should postback. I need to
check for the condition only for one asp button control.

Thanks.

Nov 29 '06 #2
the asp:button works in two ways.

1) standard html submit button. to cancel your client code returns false on
the onclick:

<input type=submit onclick='return postbackcheck();'>

2) the input is render with a onclick call to '__dopostback', usually
checking validation. here you need to duplicate the code to cancel.

the supported approach is to write a custom validator, and turn on causes
vaidation on your button.

-- bruce (sqlwork.com)

<kr*********@gmail.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
>I have asp button control on the page. I need to check some condition
before I postback the page.

Actually it is posting back for both true, false conditions.

I want to postback only if the condition is true. otherwise I want to
stay on the same page.

Note: I have many other asp buttons controls should postback. I need to
check for the condition only for one asp button control.

Thanks.
Nov 30 '06 #3

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

Similar topics

1
by: A Ratcliffe | last post by:
Hopefully just a couple of quick quick questions/responses, but its not something I've generally had trouble with in the past. Unfortunately, I need answers ASAP if anyone is available to help. ...
1
by: Rhys | last post by:
I have a page which has an IFrame on it. The src of the IFrame is a page with a datagrid on it. The Datagrid has bound template columns. The columns of the datagrid pass the bound data value of...
4
by: Chris Lane | last post by:
Hi, I have an HTML RESET button and Web Control Button that posts back to the server. Problem is the reset button doesn't work after the postback occurs. Any ideas or suggestions as to why this...
1
by: Sam Martin | last post by:
ok, so further to my previous post, i now know how to get a normal HTML control to raise a callback using the Page.GetPostBackEventReference(this, callBackRef) method, however when this is called...
2
by: Lars Netzel | last post by:
I open a popup from an aspx page and when done working in the popup i I need to update the aspx page in the background. I know how to get to the page in the background thru JavaScript...
1
by: Randall Parker | last post by:
Currently in an asp:DataGrid I have a column for bringing up an edit form on a particular row and that is done by a hyperlink as follows: <asp:TemplateColumn HeaderText="Edit Record">...
1
by: krallabandi | last post by:
I have asp button control on the page. I need to check some condition before I postback the page. Actually it is posting back for both true, false conditions. I want to postback only if the...
7
by: Tony Girgenti | last post by:
Hello. I'm trying to undetrstand ASP.NET 2.0 and javascript. When i have a button and i click on it and i see the web broswer progress bar at the bottom do something, does that mean that there...
0
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, imagine this for a moment if you will: i have a row in a gridview that when it is in edit mode there is a column that contains a dropdownlist and 2nd column that contains a user control....
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
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,...
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
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,...

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.