Reputation: 1
I have this div (popup):
<div class="info message">
<h3>Informaçã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
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
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