I am trying to use a Dialog within my webpage. I have a recordset which returns a email address.

I would like for the Dialog only to open if the recordset is empty.

This is Script so fare

<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>

Any help would be great..... PS. .. i'm doing this in dreamweaver (so noob)...

有帮助吗?

解决方案

The above works correctly. The reason it was not working for me was because my sql script was returning a result when i expect it to return nothing.

When nothing was returned then my If statement worked correctly.

Here it is in full

 <%@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>&nbsp;</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
%>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top