Public Shared Sub ShowMessageBox(ByVal
oPage As Page, ByVal
sTextToDisplay As String,
ByVal bShowButtons As
Boolean, ByVal
sBackColor As String,
ByVal sTitle As
String, ByVal
bShowTitleBar As Boolean,
ByVal bModal As
Boolean, ByVal
sMilliseconds As Integer,
ByVal iHeight As
Integer, ByVal
iWidth As Integer,
ByVal bCloseOnEscape As
Boolean, ByVal
bDraggable As Boolean,
ByVal bResizable As
Boolean, ByVal
bHideTitleBarCloseX As Boolean,
Optional ByVal
Opacity As Decimal
= 0.5, Optional ByVal
oShowStyle As ShowStyle = ShowStyle.slide, Optional ByVal
oHideStyle As HideStyle = HideStyle.bounce)
'********************************************************************************
'Notes:
'
' Sample
Call: Common.ShowMessageBox(Me.Page,
"hi steve", True, "LightBlue", "wow!", True,
True, 5000, 300, 600, True, True, True, True, 0.5, Common.ShowStyle.pulsate,
Common.HideStyle.blind)
'
'********************************************************************************
'<script
type="text/javascript"
src="http://www.schimsky.com/jquery/jquery-3.4.1.min.js"></script>
'<script
type="text/javascript"
src="http://www.schimsky.com/jquery/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
'<link
type="text/css" rel="Stylesheet"
href="http://www.schimsky.com/jquery/jquery-ui-1.12.1.custom/jquery-ui.min.css"/>
'<script
type="text/javascript">
'
' function CloseFunction(SomeValue) {
'
document.getElementById('txtHidden').value =
document.getElementById('fname').value;
' __doPostBack('cmdHiddenInputbox',
"")
' } //End CloseFunction
'
'</script>
'********************************************************************************
'********************************************************************************
'*******************************************************************************
Dim
sShowStyle As String
= "slide"
Select Case oShowStyle
Case
0
sShowStyle = "bounce"
Case
1
sShowStyle = "slide"
Case
2
sShowStyle = "fade"
Case
3
sShowStyle = "shake"
Case
4
sShowStyle = "explode"
Case
5
sShowStyle = "highlight"
Case
6
sShowStyle = "blind"
Case
7
sShowStyle = "fold"
Case
8
sShowStyle = "pulsate"
Case
9
sShowStyle = "clip"
End Select
Dim sHideStyle As String = "slide"
Select Case oHideStyle
Case
0
sHideStyle = "bounce"
Case
1
sHideStyle = "slide"
Case
2
sHideStyle = "fade"
Case
3
sHideStyle = "shake"
Case
4
sHideStyle = "explode"
Case
5
sHideStyle = "highlight"
Case
6
sHideStyle = "blind"
Case
7
sHideStyle = "fold"
Case
8
sHideStyle = "pulsate"
Case
9
sHideStyle = "clip"
End Select
'*******************************************************************************
Dim s As String = ""
s = s & "<script>$('head').append('<style>.ui-widget-overlay.ui-front
{opacity:" & Opacity & ";
}</style>');</script>"
Dim
sTitleBar As String
If
bShowTitleBar = True Then
sTitleBar = "$('.ui-dialog-titlebar').show();"
Else
sTitleBar = "$('.ui-dialog-titlebar').hide();"
End If
Dim
sHideTitleBarCloseX As String
= ""
If
bHideTitleBarCloseX = True Then
sHideTitleBarCloseX = ".prev().find('.ui-dialog-titlebar-close').hide()"
Else
sHideTitleBarCloseX = ""
End If
s = s & "<div style='background-color:" &
sBackColor.ToString & "' id='dvMessageBox'
style='display:none;' ><p>" & sTextToDisplay & "</p>
</div>"
s = s & "<script>"
s = s & "
$( function() {"
s = s & " $('#dvMessageBox').dialog({"
If
Val(sMilliseconds) > 0 Then
s = s & " open:
function(event, ui) {" & sTitleBar & "AutomaticallyClose() },"
Else
s = s & " open:
function(event, ui) {" & sTitleBar & "},"
End If
s = s & " autoOpen: true,"
s = s & " modal: " & LCase(bModal)
& ","
s = s & " position: {my: 'center', at: 'center',of:
window} ,"
's = s &
" position: {my: 'left bottom',
at: 'left bottom',of: window} ,"
s = s & " closeOnEscape: " &
LCase(bCloseOnEscape) & " ,"
s = s & " draggable: " &
LCase(bDraggable) & ","
s = s & " resizable: " &
LCase(bResizable) & ","
s = s & " width: " & iWidth & ","
s = s & " height: " & iHeight &
","
s = s & " title: '" & sTitle & "',"
If
bShowButtons = True Then
s = s & " buttons: [{ text:
'Save', click: function () { $(this).dialog('close'); CloseFunction(); } }, { text: 'Cancel', click: function () {
$(this).dialog('close'); } }],"
End If
s = s & " show: {"
s = s & " effect: '" &
sShowStyle & "',"
s = s & " duration: 1000"
s = s & " },"
s = s & " hide: {"
s = s & " effect: '" &
sHideStyle & "',"
s = s & " duration: 1000,"
'************************************************************************************************************************************************************
'appendTo:
will allow us to access the div fields from code behind, but unfortunately,
since we are creating the div, (dvMessageBox), programatically here,
' we still
wont be able to access the fields, I just lef this code here for knowledge on
how to do something like this when using other dialog routines
s = s & " appendTo: '#form1'"
'************************************************************************************************************************************************************
s = s & " }"
s = s & " })" & sHideTitleBarCloseX
& "; " '.Dialog Options
s = s & " });" 'function
'**********************************************************************************************************
s = s & "function
AutomaticallyClose(){setTimeout(function(){ $('#dvMessageBox').dialog('close');
}, " & sMilliseconds & ");}"
'**********************************************************************************************************
s = s & " </script>"
oPage.ClientScript.RegisterClientScriptBlock(oPage.GetType(), "MyUniqueKey", s)
End Sub
Public Enum ShowStyle
slide
bounce
fade
shake
explode
highlight
blind
fold
pulsate
clip
End Enum
Public Enum HideStyle
slide
bounce
fade
shake
explode
highlight
blind
fold
pulsate
clip
End Enum
<script type="text/javascript">
function CloseFunction() {
document.getElementById('txtHidden').value
= document.getElementById('fname').value;
__doPostBack('cmdHiddenInputbox', "")
} //End CloseFunction
</script>
Protected Sub cmdHiddenInputBox_Click(ByVal sender As Object, ByVal e As EventArgs) Handles
cmdHiddenInputBox.Click
Response.Write("hi
" & txtHidden.Text)
End Sub