views:

1077

answers:

3

Before meeting with Ajax and Jquery, in my projects I had a function like below.

Public Sub Raise_Alarm(ByVal p_Page As Page, ByVal p_Message As String, Optional ByVal p_IsError As Boolean = True)

strScript = "<script language= ""javascript""> alert('" & p_Message.Replace("'", "") & "')</script>"
    Dim t As Type = p_Page.GetType()
    p_Page.ClientScript.RegisterStartupScript(t, "alert", strScript)
    Dim mylabel As Label

end sub

For now I want to a function instead of function above, which show message as a lightbox (modal box).

How can I do it?

+1  A: 

Try one of the excellent jQuery plugins for displaying modal windows such as jqModal. The docs explain how to configure and launch your modal window, and include some great examples.

cxfx
I have already looked it, but I ask for how to use it in a function in code behind.
mavera
+1  A: 

If you want to use jqModal as suggested by cxfx above (+1;), this should work:

strScript = "$('<div>" & p_Message.Replace("'", "\'") & "</div>').jqm();";
ClientScriptManager.RegisterStartupScript(p_Page.GetType(), "alert", strScript, true);
ybo
+1  A: 

If you are using "thickbox" it can just display a noraml aspx page in a modal window. You can then use code behind as normal.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

<link href="/themes/ui.all.css" rel="stylesheet" type="text/css" />       
<link runat="server" href="/styles/thickbox.css" rel="stylesheet" type="text/css" />       
<!-- jQuery -->
<script type="text/javascript" src="/scripts/jquery-1.3.2.js"></script>
<script type="text/javascript" src="/scripts/ui.core.js"></script>
<script type="text/javascript" src="/scripts/thickbox.js"></script>      

</head>
<body>
       <a class="thickbox" href="mylink.aspx?KeepThis=true&TB_iframe=true&height=300&width=850">modal thick box link</a>
</body>
</html>

Hope this helps.

Jon
In fact, I tried to use it, but ı couldn't. Can you write sample code please.
mavera
This is super.I was in search for the same thing .Thanks Jon
Shyju