English 中文(简体)
• 如何用主页开放“Query UI dialog”?
原标题:How to open jQuery UI dialog in page with master page?

我想从一页总页的 as子上开一个“Query UI Dialog”。 在主页的一页中,该代码进行罚款,但总页上没有工作。

该守则是:

<%@ Page Title="" Language="vb" AutoEventWireup="false"   MasterPageFile="~/privado/master/interior.master" CodeBehind="WebForm3.aspx.vb" Inherits="ProyectoDemo.WebForm3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="headInterior" runat="server">
    <link type="text/css" href="Styles/jquery-ui-1.8.16.custom.css"    rel="stylesheet" />  
    <link href="Styles/addhunters.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui- 1.8.16.custom.min.js"></script>
    <style type="text/css">
        /*demo page css*/
        body{ font: 62.5% "Trebuchet MS", sans-serif; margin: 50px;}
        .demoHeaders { margin-top: 2em; }
        #dialog_link {padding: .4em 1em .4em 20px;text-decoration:  none;position: relative;}
        #dialog_link span.ui-icon {margin: 0 5px 0 0;position: absolute;left: .2em;top: 50%;margin-top: -8px;}
        ul#icons {margin: 0; padding: 0;}
        ul#icons li {margin: 2px; position: relative; padding: 4px 0; cursor: pointer; float: left;  list-style: none;}
        ul#icons span.ui-icon {float: left; margin: 0 4px;}
    </style>    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contenidoInterior" runat="server">
    <script type="text/javascript">
        $(function () {
            // Dialog      
            $( #dialog ).dialog({
                autoOpen: false,
                width: 600,
                height: 400,
                buttons: {
                    "Ok": function () {
                        $(this).dialog("close");
                    },
                    "Cancelar": function () {
                        $(this).dialog("close");
                    }
                }
            });
            // Dialog Link
            $( #Boton ).click(function () {
                $( #dialog ).dialog( open );
                return false;
            });
        });
    </script>

    <div id="uno">
        <h2 class="demoHeaders">Dialog</h2>        
        <asp:TextBox ID="TextBox1" runat="server" Text="prueba" ></asp:TextBox>
        <p><a href="#" id="dialog_link" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-newwin"></span>Open Dialog</a></p>              
        <asp:LinkButton ID="Boton" runat="server">LinkButton</asp:LinkButton>
        <asp:Button ID="Button1" runat="server" Text="Button" />
        <!-- ui-dialog -->
        <div id="dialog" title="Dialog Title">
            <p>Dialog text</p>            
        </div>  
    </div>

我认为,问题是如何在持股人内部提及“方言”。 我以几种方式进行了尝试,但我没有找到解决办法。

任何人都知道如何解决这一问题?

事先感谢你!

Javier

最佳回答

你们需要考虑几个问题:

  1. Add following code to a separate common.js and add it s reference to master page:

window["common"] = {
    liveDialog: function(btnId) {
         $(btnId).live(click,common.showDialog);
         return false;
    },
    showDialog() : function(){
         $( #dialog ).dialog({
                autoOpen: false,
                width: 600,
                height: 400,
                buttons: {
                    "Ok": function () {
                        $(this).dialog("close");
                    },
                    "Cancelar": function () {
                        $(this).dialog("close");
                    }
                }
            });

    }

}
  1. Add following method to master page:
public void RegisterDialog(clientBtnId)
{
    this.page.ClientScript.RegisterStartupScript(this.Page.GetType(),"__registerDialg","common.liveDialog( "+clientBtnId+" );",true);
}
  1. From your content page, cast this.MasterPage to actual class name of your master page and pass your button s clientId to RegisterDialog.

www.un.org/chinese/ga

For example your master page class name is CustomSiteMaster, you can write ((CustomSiteMaster)this.Master).RegisterDialog(button1.ClientID); -- end of edit --

它的工作将毫无问题

问题回答

添加以下内容:

<asp:LinkButton ID="Boton" runat="server" 
OnClientClick="$( #dialog ).dialog( open ); return false;" >LinkButton</asp:LinkButton>

此外,如果你想选择服务器边控制,在选择子公司后使用:

$("#<%= ControlID.ClientID %>")

2. 在内容持有人中发现任何控制,请确保使用等同物:

$( #ContentPlaceHolderId_ControlId )

j 贵重金心没有装上,因为您的<代码> rc属性有额外空间:

 <script type="text/javascript" src="js/jquery-ui- 1.8.16.custom.min.js"></script>

仅作以下改动:

<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>

并且j Query UI 可能装上罚款,你将停止接收,”该物体不支持这一财产或方法。”

我有“姐妹”的解决办法。 这个问题非常简单。 提到j Query-UI的档案是Conten1的持证人,我在Conten2的持单人中说这两条话,这一内容具有 j印功能,以便打开方言。

完整的工作法典如下:

<%@ Page Title="" Language="vb" AutoEventWireup="false"   MasterPageFile="~/privado/master/interior.master" CodeBehind="WebForm3.aspx.vb"   Inherits="ProyectoDemo.WebForm3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="headInterior" runat="server">
    <link type="text/css" href="Styles/jquery-ui-1.8.16.custom.css"    rel="stylesheet" />  
    <link href="Styles/addhunters.css" rel="stylesheet" type="text/css" />
    <%--<%@ MasterType  VirtualPath="~/privado/master/Interior.master"%>--%>
    <style type="text/css">
        /*demo page css*/
        body{ font: 62.5% "Trebuchet MS", sans-serif; margin: 50px;}
        .demoHeaders { margin-top: 2em; }
        #dialog_link {padding: .4em 1em .4em 20px;text-decoration:    none;position: relative;}
        #dialog_link span.ui-icon {margin: 0 5px 0 0;position:   absolute;left: .2em;top: 50%;margin-top: -8px;}
        ul#icons {margin: 0; padding: 0;}
        ul#icons li {margin: 2px; position: relative; padding: 4px 0;   cursor: pointer; float: left;  list-style: none;}
        ul#icons span.ui-icon {float: left; margin: 0 4px;}
    </style>    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contenidoInterior" runat="server">
    <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-   1.8.16.custom.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            alert( hola );
            $( #dialog ).dialog({
                autoOpen: false,
                width: 600,
                height: 400,
                buttons: {
                    "Ok": function () {
                        $(this).dialog("close");
                    },
                    "Cancelar": function () {
                        $(this).dialog("close");
                    }
                }
            });

            $( #MainContent_contenidoInterior_Boton ).click(function () {
                $( #dialog ).dialog( open );
                return false;
            });
        });               
    </script>

    <div id="uno" >
        <h2 class="demoHeaders">Dialog</h2>        
        <asp:TextBox ID="TextBox1" runat="server" Text="prueba" ></asp:TextBox>
        <p><a href="#" id="dialog_link" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-newwin"></span>Open Dialog</a></p>              
        <asp:LinkButton ID="Boton" runat="server">LinkButton</asp:LinkButton>
        <asp:Button ID="Button1" runat="server" Text="Button" />
        <!-- ui-dialog -->
        <div id="dialog" title="Dialog Title">
            <p>Dialog text</p>            
        </div>  
    </div>

感谢你的答复。

Javier





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!