views:

143

answers:

2

I am basically trying to do what this article says. link text I am able to postback, but my handler is not getting hit. Any ideas?

Code Behind

protected void Page_Init(object sender, EventArgs e)
 {
             WireEvents();

 }

 private void WireEvents()
 {
            btnAuthOk.Click += new EventHandler(btnAuthOk_Click);
            btnAuthOk.OnClientClick = string.Format("fnClickOK('{0}','{1}')", btnAuthOk.ClientID, string.Empty);
 }

  private void btnAuthOk_Click(object sender, EventArgs e)
  {
            DoSomeCodeHere();
  }

Javascript & HTML

  function fnClickOK(sender, e) {
        __doPostBack(sender, e);
    }

    <p>To allow this payment to be processed, enter an authorized User ID and Password</p>
    <p>User ID: <asp:TextBox runat="server" ID="txtAuthUser" CssClass="underlinedTextBox" Columns="8" />
    <asp:Literal runat="server" ID="spauth" Text="&nbsp;&nbsp;&nbsp;" />
        Password : <asp:TextBox runat="server" ID="txtAuthPass" TextMode="Password" CssClass="underlinedTextBox" Columns="10" />
    </p>
    <asp:Button runat="server" ID="btnAuthOk" Text="Submit" CssClass="popupAuthButton" UseSubmitBehavior="false"  />

</asp:Panel>

<cc1:ModalPopupExtender ID="authPE" runat="server" PopupControlID="popupAuth"
     OkControlID="btnAuthOk" TargetControlID="hdnPopupTarget" BackgroundCssClass="modalBackground" />

Thanks for any help here...

Cheers, ~ck

PS Stack is mucking my html a bit as I don't know how to properly post HTML. Is someone can edit and fix, I appreciate it. :)

A: 

If you just want your OK button to do a postback, simply remove the OkControlID attribute from your ModalPopupExtender markup.

I know, I know - that sounds ridiculous. But when you specify OK and Cancel button ID's to the MPE, it actually disables them from posting back on the client side.

womp
+1  A: 

I found that setting UseSubmitBehavior="false" actually allows me to hit my code.

Hcabnettek