我正在尝试在我的网页中使用对话框。我有一个记录集,它返回一个电子邮件地址。
如果记录集为空,我想只打开Dialog。
这是脚本如此票价
<script>
$(document).ready(function() {
$(function() {
$( "#dialog-message" ).dialog({
modal: true,
autoOpen: false,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
});
});
</script>
<div id="body">
<% If Email.EOF And Email.BOF Then %>
<div id="dialog-message" title="Error No Email address found">
<p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span> Error, you don't have an email address linked to your account. </p>
<p> You cannot request this report</b>. </p>
</div>
<% End If ' end Email.EOF And Email.BOF %>
</body>
任何帮助都会很棒..... PS。 ..我在Dreamweaver中做这个(所以noob)...
答案 0 :(得分:0)
以上工作正常。它不适合我的原因是因为我的sql脚本返回结果时我希望它什么都不返回。
当没有返回任何内容时,我的If语句正常工作。
这里是完整的
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim Recordset2
Dim Recordset2_cmd
Dim Recordset2_numRows
Set Recordset2_cmd = Server.CreateObject ("ADODB.Command")
Recordset2_cmd.ActiveConnection = MM_----------_STRING
Recordset2_cmd.CommandText = "SELECT Email FROM dbo.tblusers WHERE UserName = ? AND Email <> ''"
Recordset2_cmd.Prepared = true
Recordset2_cmd.Parameters.Append Recordset2_cmd.CreateParameter("param1", 200, 1, 50, Recordset2__varusername) ' adVarChar
Set Recordset2 = Recordset2_cmd.Execute
Recordset2_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="shortcut icon" href="../favicon.ico" >
<link rel="icon" type="image/gif" href="../animated_favicon1.gif" >
<title>-------------------</title>
<script>
$(function() {
$( "#dialog-message" ).dialog({
modal: true,
minWidth: 400,
closeOnEscape: false,
my: "center",
at: "center",
of: "#targetElement",
buttons:
{ 'Go Back': function() {
document.location = '/HeadOffice/HeadOfficeMenu.asp';
},
}
});
});
</script>
<body>
<header>
<div class="content-wrapper">
<div class="float-left">
<p class="site-title">
---------- </p>
</div>
</header>
<div id="body">
<asp:ContentPlaceHolder runat="server" ID="FeaturedContent" />
<section class="content-wrapper main-content clear-fix">
<asp:ContentPlaceHolder runat="server" ID="MainContent" />
<table width="200" border="1">
<tr>
<td><input type="button" onClick="history.go(-1)" value="Back" class="noprint" /></td>
<td> </td>
</tr>
</table>
<p>This Request will be proccessed nightly and emailed.</p>
<% If Recordset2.EOF And Recordset2.BOF Then %>
<div id="dialog-message" title="Error No Email address found">
<p> Error, you don't have an email address linked to your account.<br />
Please contact ---------------------------- and request to have your email added. </p>
<p> You cannot request this report. </p>
</div>
<% End If ' end Recordset2.EOF And Recordset2.BOF %>
</section>
</div>
<footer>
<div class="content-wrapper">
<div class="float-left">
<p>------------------
</p>
</div>
</div>
</footer>
</body>
</html>
<%
Recordset2.Close()
Set Recordset2 = Nothing
%>