Current location: Hot Scripts Forums » Programming Languages » ASP.NET » Can't Fire button event more than 1 time


Can't Fire button event more than 1 time

Reply
  #1 (permalink)  
Old 09-20-04, 12:00 AM
goatstudio goatstudio is offline
New Member
 
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Can't Fire button event more than 1 time

Hi all,

I have a web form, and my page is coded in c#.
There is a button and a label in my webform, when I click on the button, the label should display +1.

My code as below:

protected void Button_Submit_OnClick (Object Src, EventArgs E) {
Label1.Text = "Total: " + (x++);
}

x is public variable in the page. The problem is this event only fire at the first time...and seems not firing at all at the second time.

Any clue?

Thanks!

regards,
vic
Reply With Quote
  #2 (permalink)  
Old 10-19-04, 11:27 PM
thuenb thuenb is offline
Newbie Coder
 
Join Date: Oct 2004
Location: MI
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
I do not code in C# but here would be the answer in vb.net If you know how to make a if then with C# then I am sure this will help...

When you declare the public variable. Do not declare its value. Use a

Code:
If Not IsPostBack = True Then
     Public variable = "Blah"
End If
I ran into a similiar problem before. It ended up that the variable was re-initialized everytime there was a postback. This corrected it. I hope it helps...
__________________
Best Regards,
Brian Thuen
http://www.AdvisedSolutions.com
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically Running a function in PHP at a specified time or on an event RNorden PHP 2 02-26-04 06:45 AM
First time poster needs help with a mouseover submit form button mess. teh_fonx JavaScript 3 12-21-03 12:19 AM
Reduce the time intensive phases of .Net application development using TierDeveloper3 smars General Advertisements 0 12-02-03 05:15 AM
Showing time is users time zone? Nasimov PHP 1 11-20-03 07:14 AM
Dynamic Button - Urgent kamlesh_nadar ASP.NET 1 11-08-03 12:26 AM


All times are GMT -5. The time now is 12:54 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.