473,657 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1469
Hi Yama,

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

return false;

from the JavaScript function.
"Yama" <yk*****@grandp acificresorts.c om> wrote in message
news:eI******** ******@TK2MSFTN GP11.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="_in dex.aspx.vb"
Inherits="Demo. __index"%>
<html><head><ti tle>Validate</tile>
<script language="JavaS cript" type="text/JavaScript">
<!-- // Hide older browser
function validate()
{
alert("Client-Side validation!");
return false;
}
}
//-->
</script>
<body>
<table>
<tr valign="top">
<td align="center" bgcolor="#fffff f" colspan="2"><br >
<asp:button id="cmdRunRepor t" 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.EventArg s) Handles MyBase.Load
'--// If the page has already loaded do not execute it again
If Not Page.IsPostBack Then
cmdRunReport.At tributes("oncli ck") = "validate() ;"
End If
End Sub
'/// <summary>
'/// Upon click "Run Report" The user is redirected to a "Loading... " page.
'/// </summary>

Private Sub cmdRunReport_Cl ick(ByVal sender As Object, ByVal e As
System.EventArg s) Handles cmdRunReport.Cl ick
Response.Redire ct("Loading.asp x?URL=Invoice.a spx?")
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_Cl ick event. How can I prevent this from happening?

Yama

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

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

return false;

from the JavaScript function.
"Yama" <yk*****@grandp acificresorts.c om> wrote in message
news:eI******** ******@TK2MSFTN GP11.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
4780
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 Button.performclick? Thanks
2
2350
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 bt_1_click in which I created a second Button dynamically too. System.Web.UI.WebControls.Button bt_2= new Button();
6
2839
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 data from the button is not available at this time as to allow the table to properly update. So basically, I need to call UpdateTable() twice, once from page load and once from button. This causes problems with my application, and I was trying...
4
4017
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 ontop of the webform1: Public Class WebForm1 Inherits System.Web.UI.Page #Region " Web Form Designer Generated Code "
11
13917
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 all users (btnSendAll). When user hits enter, I also simulate the effect of clicking button (btnSend). However, what I found btnSend doesn't fire (unless I click on the button). The postback function I call is as follows: function...
3
8787
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 twice, once with postback true, and second time without postback. This only happens for this button. How can I sort out this issue, any clues what to look for to get this sorted please. <p>Search Bookmarks: <asp:TextBox ID="txtSearch"...
7
2573
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 upgraded to VB.NET, and I have a lot of catching up to do. That being said, I have come a long way in a short while, however, I am stumped at the moment. I have read through days of posts, but have not been able to address my specific question, so...
15
62044
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
6860
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, it is not work, anyone can tell how to use button click event ? Thanks in advance, Martin
3
21116
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....
0
8319
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8512
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8612
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7347
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.