jQuery对话框不在对话框内发回

时间:2016-02-22 16:17:02

标签: jquery asp.net

我在The error occurs when it is call by RegisterClientScriptBlock on jQuery dialog box使用了Abide Masaraure的样本。有效。

现在我需要在SQL中保存数据,然后在标签上显示消息。对话框上的页面作为整个网页打开,而不是在对话框内。我在网上搜索解决方案,但我找不到解决方案。有人会告诉我该怎么做。

提前致谢。

我从示例中修改了Test2.aspx

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Test2.aspx.vb" Inherits="WebApplication2.Test2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

 <script src="//code.jquery.com/jquery-1.10.2.js"></script>
 <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
 <script type="text/javascript"  src="script.js"></script>

  <script type="text/javascript">
        $(document).ready(function () {
        $('#btnCancel').click(function (e) {
            e.preventDefault();
            openDailogBox("", 0, 0);
        });
 });

 function Msg() {          
     if (document.getElementById('lbltest') != null) {
         alert('test');
         document.getElementById('lbltest').innerHTML = 'test';
         document.getElementById('lbltest').style.display = "block";


     } else { alert("null"); }
 }

     </script>
  <title>Dialog Box</title>
</head>
<body>
    <form id="form1" runat="server">

    <div>
      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="* Required" ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
      <asp:Button ID="btnCancel" runat="server" Text="Cancel"  />
      <asp:Button ID="btnSave" runat="server" Text="Save"  />
      <asp:Label ID="lbltest" runat="server" Text="" />

      <br />

    </div>
  </form>
</body>
</html>

有Test2.aspx.vb代码:

 Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click

    'save data on SQL then show the message
    Dim cs As ClientScriptManager = Page.ClientScript
    cs.RegisterStartupScript(Page.GetType(), "ErrorMsg", "<script>Msg()</script>", False)

End Sub

0 个答案:

没有答案