473,748 Members | 4,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Button Click events only firing on second click

I've got a problem where some buttons placed on a user
control are only firing their OnClick events when the
user clicks on them for the second time.

I've got the situation where some common functionality
(Insert/Edit/Save/Cancel) is wrapped up in a user
control. This control is embedded on several other user
controls.

I don't know if this is relevant or not but the latter
user controls (hosting the Edit/Save etc control)
mentioned above are loaded dynamically at runtime into a
PlaceHolder using Page.LoadContro l.

So running the project - The first time the user clicks
on one of the buttons nothing happens, the second time,
and every time thereafter, the OnClick event gets fired
as it should.

I've compared the source HTML in the browser for both
scenarios, and there is no difference between them

Any ideas?

Kind regards

Ben
Nov 18 '05 #1
5 11800
i think the event handlers are not mapped for the first time and second time
onwards they are mapped.
can you post your code..we can try to debug it.

Av.

"Ben Fidge" <be*******@btop enworld.com> wrote in message
news:1c******** *************** ******@phx.gbl. ..
I've got a problem where some buttons placed on a user
control are only firing their OnClick events when the
user clicks on them for the second time.

I've got the situation where some common functionality
(Insert/Edit/Save/Cancel) is wrapped up in a user
control. This control is embedded on several other user
controls.

I don't know if this is relevant or not but the latter
user controls (hosting the Edit/Save etc control)
mentioned above are loaded dynamically at runtime into a
PlaceHolder using Page.LoadContro l.

So running the project - The first time the user clicks
on one of the buttons nothing happens, the second time,
and every time thereafter, the OnClick event gets fired
as it should.

I've compared the source HTML in the browser for both
scenarios, and there is no difference between them

Any ideas?

Kind regards

Ben

Nov 18 '05 #2
I've put a breakpoint on the InitializeCompo nent method
of my UserControl, and the events are setup during the
page load both times. It's got to be something going on
client-side, even though I'm sure the javascript
__doPostBack is setup properly.

Where can I send the source code to you? I'm using a
browser based newsgroup reader as NNTP is blocked on our
firewall, and I can't attach files.

Thanks

Ben
-----Original Message-----
i think the event handlers are not mapped for the first time and second timeonwards they are mapped.
can you post your code..we can try to debug it.

Av.

"Ben Fidge" <be*******@btop enworld.com> wrote in message
news:1c******* *************** *******@phx.gbl ...
I've got a problem where some buttons placed on a user
control are only firing their OnClick events when the
user clicks on them for the second time.

I've got the situation where some common functionality
(Insert/Edit/Save/Cancel) is wrapped up in a user
control. This control is embedded on several other user
controls.

I don't know if this is relevant or not but the latter
user controls (hosting the Edit/Save etc control)
mentioned above are loaded dynamically at runtime into a PlaceHolder using Page.LoadContro l.

So running the project - The first time the user clicks
on one of the buttons nothing happens, the second time,
and every time thereafter, the OnClick event gets fired
as it should.

I've compared the source HTML in the browser for both
scenarios, and there is no difference between them

Any ideas?

Kind regards

Ben

.

Nov 18 '05 #3
Ben,

I had this same problem on a site I built. I'm not positive if this if the
fix or not, but what seemed to work is setting the client id of the user
control.

What I did is, in the page load of each user control, I set it's client id
like this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Me.ID = "StampFactsCont rol"

End Sub

This seems to have taken care of the problem, but I don't have any
confirmation that this is what fixed my project. Try it out.

Would you post here if it does fix the problem? I can't be positive that
some other change I made didn't fix things, but if it works for you then I
think that would be confirmation enough.
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Ben Fidge" <be*******@btop enworld.com> wrote in message
news:1c******** *************** ******@phx.gbl. ..
I've got a problem where some buttons placed on a user
control are only firing their OnClick events when the
user clicks on them for the second time.

I've got the situation where some common functionality
(Insert/Edit/Save/Cancel) is wrapped up in a user
control. This control is embedded on several other user
controls.

I don't know if this is relevant or not but the latter
user controls (hosting the Edit/Save etc control)
mentioned above are loaded dynamically at runtime into a
PlaceHolder using Page.LoadContro l.

So running the project - The first time the user clicks
on one of the buttons nothing happens, the second time,
and every time thereafter, the OnClick event gets fired
as it should.

I've compared the source HTML in the browser for both
scenarios, and there is no difference between them

Any ideas?

Kind regards

Ben

Nov 18 '05 #4
It works!!!!

Nice one. I would never have thought of that myself!

In my high-level .aspx page, I have a method called
LoadScreen that loads in the appropriate UserControl. I
have a TreeView control and I want to display a different
UserControl according to the type of node clicked on. In
the SelecvtedNodeIn dexChange event I call Loadscreen

Instead of putting the ID="???" in the UserControls
Page_Load, I assign an ID after calling Page.LoadContro l.
As I'm only ever going to have one UserControl on-screen
at a time I just assign a generic name (ctrlCurrent).
That way I don't have to remember to assign an ID in
every page_load of every control.

Thankyou very much. That has been bugging me for days.

Ben
-----Original Message-----
Ben,

I had this same problem on a site I built. I'm not positive if this if thefix or not, but what seemed to work is setting the client id of the usercontrol.

What I did is, in the page load of each user control, I set it's client idlike this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e AsSystem.EventAr gs) Handles MyBase.Load

Me.ID = "StampFactsCont rol"

End Sub

This seems to have taken care of the problem, but I don't have anyconfirmation that this is what fixed my project. Try it out.
Would you post here if it does fix the problem? I can't be positive thatsome other change I made didn't fix things, but if it works for you then Ithink that would be confirmation enough.
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Ben Fidge" <be*******@btop enworld.com> wrote in message
news:1c******* *************** *******@phx.gbl ...
I've got a problem where some buttons placed on a user
control are only firing their OnClick events when the
user clicks on them for the second time.

I've got the situation where some common functionality
(Insert/Edit/Save/Cancel) is wrapped up in a user
control. This control is embedded on several other user
controls.

I don't know if this is relevant or not but the latter
user controls (hosting the Edit/Save etc control)
mentioned above are loaded dynamically at runtime into a PlaceHolder using Page.LoadContro l.

So running the project - The first time the user clicks
on one of the buttons nothing happens, the second time,
and every time thereafter, the OnClick event gets fired
as it should.

I've compared the source HTML in the browser for both
scenarios, and there is no difference between them

Any ideas?

Kind regards

Ben

.

Nov 18 '05 #5
Ben,

Your welcome. Thanks for confirming this fix for me!

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Ben Fidge" <be*******@btop enworld.com> wrote in message
news:1c******** *************** ******@phx.gbl. ..
It works!!!!

Nice one. I would never have thought of that myself!

In my high-level .aspx page, I have a method called
LoadScreen that loads in the appropriate UserControl. I
have a TreeView control and I want to display a different
UserControl according to the type of node clicked on. In
the SelecvtedNodeIn dexChange event I call Loadscreen

Instead of putting the ID="???" in the UserControls
Page_Load, I assign an ID after calling Page.LoadContro l.
As I'm only ever going to have one UserControl on-screen
at a time I just assign a generic name (ctrlCurrent).
That way I don't have to remember to assign an ID in
every page_load of every control.

Thankyou very much. That has been bugging me for days.

Ben
-----Original Message-----
Ben,

I had this same problem on a site I built. I'm not

positive if this if the
fix or not, but what seemed to work is setting the

client id of the user
control.

What I did is, in the page load of each user control, I

set it's client id
like this:

Private Sub Page_Load(ByVal sender As System.Object,

ByVal e As
System.EventAr gs) Handles MyBase.Load

Me.ID = "StampFactsCont rol"

End Sub

This seems to have taken care of the problem, but I

don't have any
confirmation that this is what fixed my project. Try it

out.

Would you post here if it does fix the problem? I can't

be positive that
some other change I made didn't fix things, but if it

works for you then I
think that would be confirmation enough.
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Ben Fidge" <be*******@btop enworld.com> wrote in message
news:1c******* *************** *******@phx.gbl ...
I've got a problem where some buttons placed on a user
control are only firing their OnClick events when the
user clicks on them for the second time.

I've got the situation where some common functionality
(Insert/Edit/Save/Cancel) is wrapped up in a user
control. This control is embedded on several other user
controls.

I don't know if this is relevant or not but the latter
user controls (hosting the Edit/Save etc control)
mentioned above are loaded dynamically at runtime into a PlaceHolder using Page.LoadContro l.

So running the project - The first time the user clicks
on one of the buttons nothing happens, the second time,
and every time thereafter, the OnClick event gets fired
as it should.

I've compared the source HTML in the browser for both
scenarios, and there is no difference between them

Any ideas?

Kind regards

Ben

.

Nov 18 '05 #6

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

Similar topics

0
1834
by: Anina | last post by:
It looks like the button control captures all of the clicks on the button no matter if the program is busy accessing code. For example: if the click event of a button has code that takes 10 seconds to process, and I click it, and I continue to click on the button 100 times *while the code is being processed* windows will queue all of those clicks, and the button click event will run 100 click events after it's done processing the original...
2
1415
by: Michael Johnson Jr. | last post by:
here is the problem, I have a table with dynamic buttons and events. On buton click of said row, it would clear the rows in the table, and repopulate it. This works fine the first time you run the app on the first click. Every other attempt to click one of these buttons fires a page load only, upon the 2nd click a button click event is fired. This was verified by adding a list box to the page, in Page_Load and Button_Click event adding...
8
11165
by: walesboy | last post by:
greetings - I have a btnSubmit button with a Handles btnSubmit.click which works great if all the user does is click that button. But, if the user ALSO changes a text box on the page (which has it's own event and autopostback=true) before clicking submit then it fires the text box event but never fires the btnSubmit event. (I follow it in the trace). Surely both event handlers should be fired? Any hints on identifying what I
5
5848
by: kai | last post by:
Hi, In ASP.NET , what is the difference between OnClick and Click events for a button? Because we have button click event, it can trigger events, why we still need OnClick? Please help. Thanks kai
1
3135
by: Vi | last post by:
Hi, I have an ASP.NET web app and for some reason the Button Click Events are not firing. I ran C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -c and it created the aspnet_client folder, but it doesn't contain any files and it's still not working. I'm kind of stuck here so any suggestions will be much appreciated. Thanks.
2
4282
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()...
5
6760
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created link buttons to stay wired up to their click events. I have what is basically a simply survey question generation page. The page first displays a few static fields and a dropdownlist of various options for the user to select. When the user...
3
1950
by: Leo Smith | last post by:
I have a problem with some code that fires an onclick event for an image. What I did was create a group of images to work like a button. The mouseover, mousedown, and mouseout events swap images to give a nice feel to the button, but when the onclick event is fired, which was created as follows: string s = Page.ClientScript.GetCallbackEventReference(this, "ChangeClockSetting(this)", "ResfreshClockSetting", "null",...
0
1520
by: =?Utf-8?B?Smlt?= | last post by:
I have an application that was built using asp.net 1.1. The application interviews the user with a parent form that loads a series of web user controls (.ascx files)dynamically with page.loadcontrol. It needs to be dynamic because the next user control loaded is based on the answer to the previous question. The application has worked flawlessly for many years. I recently upgraded the application to .net 2.0 and found that the button...
2
2815
by: chrisp | last post by:
I have an ASP.NET 2 page with a button that causes a credit card transaction to be authorised. The authorisation procedure may take a few seconds and so I want to prevent the user from clicking the button again (or at least detect that an authorisation is already in progress and do nothing) while the first authorisation is in progress. Can someone help me out? I've tried the following but none of the solutions work: 1) Disabling the...
0
9370
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...
0
9247
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
8242
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...
1
6796
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
4602
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
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
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
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
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.