• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1176
  • Last Modified:

Button's onCommand event wont fire

Been at this all morning.

I have a Div and a Panel.
--Inside the Div , I have a linkbutton, an ajaxToolkit:ModalPopupExtender and a grid.
--Inside the panel, I have a table and 2 buttons. Cancel and Add. Ajax ModalPopup uses pops up this panel.
-- For the Add button, I have an OnCommand event. In the code behind, I have an event for it.

*** I click on the linkbutton, the modal panel screen pops up. All is good. I click "Add" button BUT the event is not fired. I tried onClick, put debug, but nothing.

*** As a test, I added onClientClick and a test Javascript. THIS WORKS. Javascript alert test pops up.

Not sure why the Button event wont fire. *** NOTE: if I move the panel and the linkbutton and the Ajax control INSIDE the grid, then the event fires. But it should work outside a grid as well.

This is what I have:  It's like the button wont post back.
<div id="pnlOrderNotes" runat="server">
            <fieldset>
                <legend>
                   Order Notes <asp:LinkButton ID="lbAddNote" runat="server" Text="Add Note"/>
                </legend>
                 
              <ajaxToolkit:ModalPopupExtender  BackgroundCssClass="modalBackground"  TargetControlID="lbAddNote" PopupControlID="pnlAddNote"
                                                 ID="ModalPopupExtender1" OkControlID="btnNoteAdd1"  CancelControlID="btnNoteCancel" runat="server">
                    
              </ajaxToolkit:ModalPopupExtender>  
                  <table> 
                          ....
                           <grid>...
-------------------
 
<asp:Panel runat="server" CssClass="modalPanel" Width="50%"  ID="pnlAddNote">
 
<table cellpadding="2" cellspacing="0" border="0" width="100%">
<tr>
              <td>
                <asp:Button ID="btnNoteCancel" runat="server" Text="Cancel" />
              </td>
              <td>
               <asp:Button ID="btnNoteAdd1"   OnCommand="btnNoteAdd1_onClick"   runat="server" Text="Add  " />
              </td>
            </tr>
 
------------------
protected void btnNoteAdd1_onClick(object sender, CommandEventArgs e)
    {

Open in new window

0
Camillia
Asked:
Camillia
  • 4
  • 3
1 Solution
 
burakiewiczCommented:
dont set them as the ok and cancel control. just leave them blank
0
 
burakiewiczCommented:
<ajaxToolkit:ModalPopupExtender  BackgroundCssClass="modalBackground"  TargetControlID="lbAddNote" PopupControlID="pnlAddNote" ID="ModalPopupExtender1" runat="server"/>
0
 
CamilliaAuthor Commented:
really? let me see. I hope you're right. Let me try and will post back.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
CamilliaAuthor Commented:
OH MY GOD. YES. YOU'RE RIGHT :)

You're the best. Have spent 5 hours on this. The senior developer didnt know. THANKS.

So, when do i use that ok and cancel??

Kamila.
0
 
burakiewiczCommented:
i set it once and had that happen to me.
you can set the cancel one if you dont do any processing. it will just close the window.same as calling modalpopup.Hide().  If you set the ok and cancel buttons and want them to do something you can set the onokscript and oncancelscript.
0
 
CamilliaAuthor Commented:
You saved my day. Thanks so much.

Kamila.
0
 
burakiewiczCommented:
no prob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now