473,395 Members | 1,639 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.

Help with button text

Can somebody help me with this simple problem:

I have an asp.net button and I want to make "if" statement that depends
of button label ( or caption text), i tried like this:

private void Button0_Click(object sender, System.EventArgs e)
{
if (Button0.text == "one")
{
// do something.....
}
else
{
// do something else....
}
}

....but I got an error "object reference not set to an instance of an
object"

Can someone help me a little with this ?

Thanks

Thanks

May 3 '06 #1
1 1804
Hi,

"Aahz" <ju*******@hotmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
Can somebody help me with this simple problem:

I have an asp.net button and I want to make "if" statement that depends
of button label ( or caption text), i tried like this:

private void Button0_Click(object sender, System.EventArgs e)
{
if (Button0.text == "one")
{
// do something.....
}
else
{
// do something else....
}
}

...but I got an error "object reference not set to an instance of an
object"

Can someone help me a little with this ?


How are you initializaing Button0 ?
Also are you sure the error is in the comparision?

try this:

if ( ((Button)sender).Text == ".... )
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
May 3 '06 #2

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

Similar topics

3
by: aToaster | last post by:
Hey guys, I'm just getting the hang of Python and Tkinter and I could use some help. I wrote most of the gui for my calculator program, well I haven't gotten around to putting in the...
2
by: Sudheer Kareem | last post by:
Dear All Please tell me how to assosiate help files with my Vb.net Project. Regards Sudheer
5
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action...
2
by: MyNameIsnt | last post by:
Can anyone tell me why, when I click on the buttons it register 2 characters on the display? if you use the right mousebutton it works ok, but the buttons dont flash?? it works fine without the...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
2
by: Brian | last post by:
I am very new to VB.NET and I just need some help in a listbox matter. I don't need suggestions on how to make the overall code better. I will get there. I want to move an item from one list box...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
4
by: glbdev | last post by:
Hi, I posted this question yesterday but didn't get the answer I needed. I am DESPERATE to get this working so I'm re-posting it because I don't think I worded it correctly. I have a GridView...
0
by: Kevin McKinley | last post by:
Below i've put the code for a program that i wrote. I need help on lines 384-403. If you run this program you will notice on the first tab when have it produce an answer the $ is surrounded with...
0
by: Guilherme Polo | last post by:
On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <kem1723@yahoo.comwrote: Come on.. "help on lines 384-403", that is not a good way to look for help. You are supposed to post some minimal code that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.