I have a Page which has a Control on it with 2 textboxes (username and password) and an asp:Button. If the user’s membership is going to expire within 30 days and the button is clicked, I want the JQuery dialog to popup. Inside the JQuery dialog, I have some text and an asp:LinkButton. The link button has an event attached to it, but it is not being fired when I click it in the dialog box. Here is the script tags for the JQuery:
<script type='text/javascript' src='jquery-1.3.2.js'></script> <script type='text/javascript' src='ui.core.js'></script> <script type='text/javascript' src='ui.draggable.js'></script> <script type='text/javascript' src='ui.resizable.js'></script> <script type='text/javascript' src='ui.dialog.js'></script>
Here is the script the dialog: For testing, I am closing the dialog on Renew Membership click, but I actually want it to fire a method I create in asp.net to direct the user to a another page and pass a session variable.
<script type='text/javascript'> $(document).ready(function() { $('#dialog').dialog({ // autoOpen: false, modal: true, buttons: { 'Renew Membership': function() { $(this).dialog('close'); } } }); }); </script> <asp:Content ID='mainContent' runat='server' ContentPlaceHolderID='Content'> <div id='dialog' title='Membership Renewal'> <p>Uh Oh! Your membership is going to expire.</p><br /> <p>Hurry up and renew today!</p><br /> <asp:LinkButton runat='server' Text='Click Here to Renew' onclick='Unnamed2_Click'></asp:LinkButton> </div>
Here is the click event for the LinkButton:
protected void Unnamed2_Click(object sender, EventArgs e) { UserProfiles userProfile = (UserProfiles)Session['userProfile']; Response.Redirect('~/Renew.aspx'); }
What should happen is that when the user clicks the sign-in button, it should popup up the dialog only if the days they have left to expire is <= 30 and if they do, they have the option of clicking the link in the dialog and going to a renew page where I want to pass it a Session variable with a Profile, but that is not being called, so I guess, I would like to know is how can I add the event handler of the button to the dialog and is there a way to set it so that it only comes up once, for example adding a cookie to the users browser and only showing it if they don’t have a cookie set.
I believe this is more of an ASP.NET issue and not a jQuery dialog issue.
I wouldn’t use the onClick and PostBackUrl within the same LinkButton. So, take off the PostBackUrl attribute and instead use
If you only need to show the control when the user is > 30 days. I would create a user control.
jquery.renewDialog.js
RenewalUserControl.ascx
Login.aspx
Login.aspx.cs