473,396 Members | 2,024 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.

Button Click Event

Hi,

I have a button which is a server-side control. If a client-side error on a
form is produced and a javascript (client-side) is fired how do I avoid the
server-side button_client event to occur? (that is because the page gets
refreshed for no reason even if I say do nothing)

Thank you,

Yama
Nov 17 '05 #1
2 1452
Hi Yama,

If you don't want the post to go ahead, use

return false;

from the JavaScript function.
"Yama" <yk*****@grandpacificresorts.com> wrote in message
news:eI**************@TK2MSFTNGP11.phx.gbl...
Hi,

I have a button which is a server-side control. If a client-side error on a
form is produced and a javascript (client-side) is fired how do I avoid the
server-side button_client event to occur? (that is because the page gets
refreshed for no reason even if I say do nothing)

Thank you,

Yama

Nov 17 '05 #2
Hi Oliver,

I am returning false. Here is what I am doing...

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="_index.aspx.vb"
Inherits="Demo.__index"%>
<html><head><title>Validate</tile>
<script language="JavaScript" type="text/JavaScript">
<!-- // Hide older browser
function validate()
{
alert("Client-Side validation!");
return false;
}
}
//-->
</script>
<body>
<table>
<tr valign="top">
<td align="center" bgcolor="#ffffff" colspan="2"><br>
<asp:button id="cmdRunReport" runat="server" text="Run
Report"></asp:button><br>
<br>
</td>
</tr>
</table>
</body>
</html>

Behind-Code

'/// <summary>
'/// The main entry point for the application.
'/// First validate on client-side
'/// </summary>

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'--// If the page has already loaded do not execute it again
If Not Page.IsPostBack Then
cmdRunReport.Attributes("onclick") = "validate();"
End If
End Sub
'/// <summary>
'/// Upon click "Run Report" The user is redirected to a "Loading..." page.
'/// </summary>

Private Sub cmdRunReport_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdRunReport.Click
Response.Redirect("Loading.aspx?URL=Invoice.aspx?" )
End Sub

The problem is that when I click on the button is will execute the validate
client-side function but it will also execute the server-side
cmdRunReport_Click event. How can I prevent this from happening?

Yama

"Oliver" <DE*******************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Yama,

If you don't want the post to go ahead, use

return false;

from the JavaScript function.
"Yama" <yk*****@grandpacificresorts.com> wrote in message
news:eI**************@TK2MSFTNGP11.phx.gbl...
Hi,

I have a button which is a server-side control. If a client-side error on a form is produced and a javascript (client-side) is fired how do I avoid the server-side button_client event to occur? (that is because the page gets
refreshed for no reason even if I say do nothing)

Thank you,

Yama

Nov 17 '05 #3

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

Similar topics

4
by: yfng | last post by:
In a web form, I want the user clicks on one button and this button will trigger another button/link which will open a new browser window? How to do that? Is there any method like...
2
by: Liqun Xu | last post by:
Hallo NG, I created a Button with Click-Event dynamically: System.Web.UI.WebControls.Button bt_1 = new Button(); bt_1.Click += new EventHandler(bt_1_click); and I implemented the Funktion...
6
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new...
4
by: Mark Lingen | last post by:
I've found a problem with postback event handling and webcontrol buttons. Try out the following code in an ASP.Net project and you will see. Create a web project in VB.Net and drop this code...
11
by: CW | last post by:
I have message entry screen that's causing me a bit of an issue. At the moment, there are 2 buttons, one is used to send message to another user (btnSend) and another is used to send messages to...
3
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called...
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
15
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
7
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
Hi, All, I create button in the code ( Dim Button as new Button), not using button web component (means not drap button and drop it ont he webform), after that I try to use button_click event,...
3
by: GauravGupta | last post by:
i want to know that is it posible to call button click event before page load event on post back.... please help me....
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
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
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.