user2560612
user2560612

Reputation: 1

open jquery popup from codebehind (ASP.Net VB)

I have this div (popup):

<div class="info message">
         <h3>Informa&ccedil;&atilde;o</h3>
         <p>Mensagem informativa.</p>
</div>

And I have this "button" (working ok) to call the div (popup):

 <ul id="trigger-list">
         <li><a href="#" class="trigger info-trigger">Info</a></li>
  </ul>

But I don't wan't to use that button, how can I call this div (popup) from code behind? example:

Sub Info(sender As Object, e As System.Web.UI.ImageClickEventArgs)
        If ChkInfo.Checked Then

'Code to show the div (popup

Else

'Another code

End Inf

End Sub

Note: I'm using this: http://www.red-team-design.com/cool-notification-messages-with-css3-jquery

thanks

Upvotes: 0

Views: 1339

Answers (2)

Adrian Wragg
Adrian Wragg

Reputation: 7401

You cannot directly trigger the opening of your popup from the code-behind, however you can output code that triggers it for you using ClientScriptManager.RegisterStartupScript; Me.ClientScript will return you a ClientScriptManager object that you can use. Example:

    Me.ClientScript.RegisterStartupScript(GetType(Page), _
        "Popup", "showMessage('info');", true)

which will output:

    <script type="text/javascript">
        showMessage('info');
    </script>

to the webpage. More information on MSDN at http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerstartupscript.aspx.

Upvotes: 3

Chirag Vidani
Chirag Vidani

Reputation: 2587

You can try this method. Make the div of message or popup to runat="server" and assign it ID. Initially you make it to visible false. So its HTML will not be generated. Now click of button to show popup this HTML will not be found, so nothing will happen.

Now you can set it visible=true on click event on server side. This will render HTML and code to display popup should be placed in document.ready()

Queries welcomed

Upvotes: 1

Related Questions