0

The button is derived from user control. I want to associate a pop-up window on click of that particular butoon. I can able to achieve this on click of anyother buttons on my base page but as that particular button is coming from a user control I am not able to trigger the pop-up window.

$('#btnSendOrder').click(function() {// code here}) // btnSendOrder is from a user control.In this case pop-up is not coming.

$('#btnSendOrder').click(function() { // code here}) // btnSend Order is from the base page itself. In this scenario pop-up comes out.  
p.campbell
  • 98,673
  • 67
  • 256
  • 322
  • Maybe I am seriously missing something here - you forgot to tell us what programming language/paradigm this is.Just a lot of talk about buttons and popups... – Shane C. Mason Jun 19 '09 at 16:20
  • I'm sorry, I don't understand the question. The two code samples are functionally, identical. You need to explain the context. What are 'user control' and 'base page' referring to? – Kieran Hall Jun 19 '09 at 16:26
  • You should really consider adding the server tag instead of hardcoding the id, asi it won't work if your usercontrol changes containers. Check my answer for a better way to do it – juan Jun 19 '09 at 16:51

3 Answers3

1

Since the button is being rendered on the server, its client ID is not what you are using

You can do this...

$('#<%= btnSendOrder.ClientID %>').click(function() {// code here}) 

... from your usercontrol, and the portion between <% and %> will be replaced with the real control id in the client html

juan
  • 80,295
  • 52
  • 162
  • 195
0

Using a bit of jquery, it would be relatively trivial to associate the button with a click event on load of the page:

    $(".button").click(function() {
        PopupMyWindow();
    });
Paddy
  • 33,309
  • 15
  • 79
  • 114
0

If you are using .NET, reember that your controls will end up looking something like: ctl1.UserControlName.ButtonName or something like that.

Check your markup code once it is rendered, then use the exact button name so that your jQuery knows which control to fire from.

Jack Marchetti
  • 15,536
  • 14
  • 81
  • 117
  • Also take a look at what @Juan Manual did below. Ideally you should grab the ClientID, instead of hard coding it because depending on where that button lives in your app, its clientID might change. Just a heads up. – Jack Marchetti Jun 19 '09 at 16:57