【问题标题】:how to use jquery Dialog (popup) in user control asp.net?如何在用户控件asp.net中使用jquery Dialog(弹出)?
【发布时间】:2014-05-21 07:42:36
【问题描述】:

当用户在 asp.net 中单击带有用户控件的按钮时,我想制作一个弹出对话框,但由于对话框根本没有打开,我一直失败。 这是我的 .ascx 文件中的内容:

<div id="dialog" title="Basic dialog">
<p>some text here</p>
</div>
<script>
$(function () {
    $("#dialog").dialog();
});

这是我的 .aspx 文件中的内容:

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
    <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"  type="text/javascript">    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Button ID="btnR" runat="server" Text="Requirements" CssClass="btn btn-info pull-right" />
</asp:Content>

我的母版页中有 jquery 1.11.0 min 那么我做错了什么,对话框没有弹出? 提前谢谢你

【问题讨论】:

  • 我希望你已经关闭了
  • 如果你想在按钮点击事件上打开对话框,你必须确保按钮不会触发返回 false 的回发以取消回发。
  • @Daniele94 :是的,我有......它只是发布时缺少的标签
  • @RandRandom : 我怎样才能使它成为 Ispostback?
  • 你应该像这样防止回发stackoverflow.com/questions/683746/…

标签: c# javascript jquery asp.net


【解决方案1】:

您的脚本应如下所示:

function dialog(){
    $("#dialog").dialog();
};

你的按钮应该是

<asp:Button ID="btnR" runat="server" Text="Requirements" CssClass="btn btn-info pull-right" CausesValidation="false" UseSubmitBehavior="false" OnClientClick="dialog(); return false;" AutoPostBack="false" /> 

【讨论】:

  • 这里有一些文字

  • 上面的说法不行吗?顺便说一句,您的脚本中不需要“$(”
  • 这里有一些文字

    还是不行!
  • 等等,我应该在哪里使用我的 来准确导入我的 ascx 文件??
猜你喜欢
  • 2011-05-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-18
  • 1970-01-01
  • 1970-01-01
  • 2023-04-05
相关资源
最近更新 更多