Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try this: </p> <p>In the HTML of the <strong>MasterPage</strong>: </p> <p>Define an event handler for <strong>LinkButtonLogin</strong>'s onclick event:</p> <pre><code>&lt;asp:linkbutton id="LinkButtonLogin" runat="server" text="Login" onclick="LinkButtonLogin_Click"&gt;&lt;/asp:linkbutton&gt; </code></pre> <p>Create a dummy button that is hidden from view. Then, for the <strong>ModalPopupExtender</strong>, change the <strong>TargetControlID</strong> of the <strong>ModalPopupExtender</strong> control from <strong>LinkButtonLogin</strong> to <strong>ButtonInvisible</strong>. This effectively fakes the <strong>ModalPopupExtender</strong> into being hideable/showable from your code.</p> <pre><code>&lt;asp:button id="ButtonInvisible" runat="server" style="display: none;" /&gt; </code></pre> <p>In the codebehind of the <strong>MasterPage</strong>:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { /* This adds a client-side event to your HyperLink control that mimics LinkButtonLogin's onclick event, but ONLY if the current user is not logged in. */ if (!UserIsLoggedIn()) { HyperLinkUserList.Attributes.Add("onclick", "document.getElementById('" + LinkButtonLogin.ClientID + "').click();"); } } protected void LinkButtonLogin_Click(object sender, EventArgs e) { // check if the user is logged in. if (!UserIsLoggedIn()) { // show the modal login window ModalPopupExtender.Show(); } else { /* This assumes that you always want a user to go to the UserList page upon being logged in. You can add some code here to redirect to different pages based on certain criteria. */ Response.Redirect("userlist.aspx"); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload