473,790 Members | 2,561 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Button click

This question might be very trivial but how can I check that a button
is clicked. Is there a way to do something like:
if(button is clicked)
{
....
}
Thanks
Celine
Nov 16 '05 #1
6 23539
Celine,

why button click event handler cannot do this for you?

HTH
Alex

"Celine" <sq*****@yahoo. fr> wrote in message
news:f3******** *************** **@posting.goog le.com...
This question might be very trivial but how can I check that a button
is clicked. Is there a way to do something like:
if(button is clicked)
{
...
}
Thanks
Celine

Nov 16 '05 #2
"Celine" <sq*****@yahoo. fr> wrote in message news:f3******** *************** **@posting.goog le.com...
This question might be very trivial but how can I check that a button
is clicked. Is there a way to do something like:
if(button is clicked)
{
...
}
Thanks
Celine


If I understand your question, you don't program this way any more. Instead use events. The easiest way to do this is to place a
button on the form and double click it. The function that is created will be called when someone clicks the button. Put the code you
want in there.

--
Michael Culley

Nov 16 '05 #3

"Celine" <sq*****@yahoo. fr> wrote in message
news:f3******** *************** **@posting.goog le.com...
This question might be very trivial but how can I check that a button
is clicked. Is there a way to do something like:
if(button is clicked)
{
...
}
Thanks
Celine


Assuming you're working in Visual Studio .NET, the click event is the
default event for a Button object, and you can obtain a proper event
procedure shell by double-clicking on the button in question, in design
view.

private void button1_Click(o bject sender, System.EventArg s e)

{
}

Place the code you want to execute when the button is clicked in this event
procedure.

Caveat: this example is from a Windows application where the name of the
button object is button1.

Hope this helps.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 16 '05 #4
Hi,

By default, buttons doesn't store the state information like whether the
button is clicked or not.

So declare a boolean private variable.

In the button click event, set the value for your boolean variable.

Now you can access the variable and can tell that whether the button is
clicked or not.

Regards,
R.Balaji

"Celine" <sq*****@yahoo. fr> wrote in message
news:f3******** *************** **@posting.goog le.com...
This question might be very trivial but how can I check that a button
is clicked. Is there a way to do something like:
if(button is clicked)
{
...
}
Thanks
Celine

Nov 16 '05 #5
Further to Peter's Explanation I have a very simple event driven app here,
that shows the code.
http://www.publicjoe.f9.co.uk/csharp/csharp10.html

Hope this helps

Publicjoe
C# Tutorial at http://www.publicjoe.f9.co.uk/csharp/tut.html
C# Snippets at http://www.publicjoe.f9.co.uk/csharp/snip/snippets.html
C# Ebook at http://www.publicjoe.f9.co.uk/csharp/samples/ebook.html

"Peter van der Goes" <p_**********@t oadstool.u> wrote in message
news:ua******** ******@TK2MSFTN GP12.phx.gbl...

"Celine" <sq*****@yahoo. fr> wrote in message
news:f3******** *************** **@posting.goog le.com...
This question might be very trivial but how can I check that a button
is clicked. Is there a way to do something like:
if(button is clicked)
{
...
}
Thanks
Celine
Assuming you're working in Visual Studio .NET, the click event is the
default event for a Button object, and you can obtain a proper event
procedure shell by double-clicking on the button in question, in design
view.

private void button1_Click(o bject sender, System.EventArg s e)

{
}

Place the code you want to execute when the button is clicked in this

event procedure.

Caveat: this example is from a Windows application where the name of the
button object is button1.

Hope this helps.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.

Nov 16 '05 #6
Thank you all for your answers, it really helped
Celine

"R.Balaji" <rb********@hot mail.com> wrote in message news:<OM******* ******@TK2MSFTN GP11.phx.gbl>.. .
Hi,

By default, buttons doesn't store the state information like whether the
button is clicked or not.

So declare a boolean private variable.

In the button click event, set the value for your boolean variable.

Now you can access the variable and can tell that whether the button is
clicked or not.

Regards,
R.Balaji

"Celine" <sq*****@yahoo. fr> wrote in message
news:f3******** *************** **@posting.goog le.com...
This question might be very trivial but how can I check that a button
is clicked. Is there a way to do something like:
if(button is clicked)
{
...
}
Thanks
Celine

Nov 16 '05 #7

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

Similar topics

6
2856
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
4031
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
13952
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
8819
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
41837
by: code100579 | last post by:
Hi there, sorry if this is a really simple question. I need to write code for: If a button is pushed and then one variety of other buttons is pushed then certain options on the program will become "greyed out". Ie they can no longer be selected. I assume i need to create an event from the first button being pushed and then do if statements depending which button is pushed next
2
4284
by: dunderhead | last post by:
Hello, I am having a problem with function and class syntax. I have one class (MakePanel1) that creates a button and label. The button-click event of the button is linked to a function (daclick1) that changes the text of the label. This works well. I have another class (MakePanel2) that creates a second button. I want this second button to call the button-click function of the first button. My incorrect call MakePanel1.daclick1()...
7
6870
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
21179
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
7025
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the page has multiple button such login page with a search function somewhere around, then it's not respond properly. I have attached a brief example of two text boxes and two button. When ever a key is press on textbox one, I want to trigger...
0
2903
by: ADN | last post by:
Hi, I am currently extending the GridView control and would like to add a button to the GridView so that it will automatically render one button at the top of the grid. I have a click event for that button, but everytime the button is clicked, the page posts back and the click event does not fire (probably because the button gets created every single time there's a postback). What is the best way for me to create this button and then...
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10413
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10145
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,...
1
7530
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
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...
1
4094
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
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.