|
-
Jun 22nd, 2005, 08:05 AM
#1
Thread Starter
Junior Member
Button click not firing
I have a problem with a web form I am developing. The problem is that the button click event does not fire when the user presses the button- the page re-loads, but the code behind the button never gets executed.
Admitedly I am a little new to this (and mainly a VB6 guy), so it is possible that I am missing an important concept here- but I have used buttons on other web forms before and had no problems. The main difference is that on this form the button is nested inside a table (though if I move it out, it still does not work).
There is also a calendar control and a few scrolling datagrids on the form- nothing fancy.
Button code is as follows
Code:
<P align="center">
<FONT face="Arial">
<asp:button id="cmdAddJob"
runat="server" Text="Add Job" Height="22px" Width="96px">
Code behind is quite simple:
VB Code:
Private Sub cmdAddJob_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddJob.Click
AddTempJob()
End Sub
Thanks for any help!
-
Jun 22nd, 2005, 08:24 AM
#2
Junior Member
Re: Button click not firing
Hi! Have you got this declared in your code behind(at the top of your webform class?)
Code:
Protected WithEvents cmdAddJob As System.Web.UI.WebControls.Button
tsami
Sami Antero
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
no smileys, no funky certificates. Sorry.
-
Jun 22nd, 2005, 08:30 AM
#3
Thread Starter
Junior Member
Re: Button click not firing
-
Jun 22nd, 2005, 08:39 AM
#4
Junior Member
Re: Button click not firing
...and you've closed the button tag?
Code:
<asp:button id="cmdAddJob" runat="server" Font-Names="Arial"></asp:button>
Are you working with vs2003 btw? If you are, go to the designer mode and double click your button to ensure that the event wiring is ok.
tsami
Sami Antero
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
no smileys, no funky certificates. Sorry.
-
Jun 22nd, 2005, 09:04 AM
#5
Thread Starter
Junior Member
Re: Button click not firing
Sorry, yes, I did close the tag, and the designer behaves as expected.
-
Jun 22nd, 2005, 11:23 AM
#6
Lively Member
Re: Button click not firing
dear friend
i dont know bout vb much.how does i work
but while working in C# as codebehind i faced siimilar problem .for that we have to write systemhandler for the control if it is missing in initializecomponent.
hope this helps
you can find similar thing for VB
-Sachien
-
Jun 22nd, 2005, 12:23 PM
#7
Thread Starter
Junior Member
Re: Button click not firing
Well, more info but more puzzling:
I can re-create the page by adding new controls and get something that works as expected.
I noticed that if I move the button to another location it can 'break' the click event- removes the Handles cmdAddJob.click from the event code ?!?
I can get it working now but I am stumped as to what causes the behavior.
Last edited by D22353; Jun 22nd, 2005 at 12:31 PM.
-
Jun 22nd, 2005, 03:07 PM
#8
Frenzied Member
Re: Button click not firing
The designer will mess you up. Use html view at all times if you can. also a sure fire way to have your event fire is to set onclick="name_of_click_handler" in the button tag.
Magiaus
If I helped give me some points.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|