0

I have yet another strange need. I have a jQuery dialog that has a dynamic button (

My Button that will be "fired":

<asp:Button ID="RenewSubscriptionButton" runat="server" Visible="false" />

My Hidden input with the postback val:

<input type="hidden" id="RenewSubscriptionPostBackValue" runat="server" />

In my page_load:

Me.RenewSubscriptionPostBackValue.Value = _
       Me.Parent.Page.ClientScript.GetPostBackEventReference _
      (Me.RenewSubscriptionButton, String.Empty)

AddHandler Me.RenewSubscriptionButton.Click, AddressOf RenewSubscription

In my Asp.net control I have a js function that is called and evaluates the __doPostBack that is generated:

$('#mgrSubPanel').dialog('destroy');
// cause postback and have it run the workflow...
eval($("#<%= RenewSubscriptionPostBackValue.ClientID %>").val());

It causes postback but doesn't call my function RenewSubscription that's in my code behind. Not sure if the addressing is failing or what but maybe one of you can see my fault and correct me...

Thanks in advance...

clockwiseq
  • 4,189
  • 9
  • 38
  • 61
  • After doing a little more research, I found out that it IS actually calling the button's actual click event but not my addressed function so I can live with that... – clockwiseq Apr 13 '10 at 21:00

2 Answers2

0

What happens when you add this PostBackEventReference script to a simple "onlick"? That is generally how I use it... your syntax here had me mystified for a minute there. :| (I'm not really used to jQuery though)

Also, when you say "dynamic button" what exactly do you mean?

Bryan
  • 8,748
  • 7
  • 41
  • 62
0

You can simplify the code quite a bit by just clicking the button via jQuery, like this:

$('#mgrSubPanel').dialog('destroy');
$("#<%=RenewSubscriptionButton.ClientID %>").click();

This will be as if the user clicked the button directly, no need for the extra <input> or the GetPostBackEventReference code, just keep the handler for the button itself (AddHandler Me...) and you're all set.

Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155