通过 Ajax 或 jQuery 的 ASP.NET 浮动 Div 菜单

发布于 2024-11-26 14:54:31 字数 1530 浏览 2 评论 0原文

问题:我有一个母版页,规定了 css、html、head、body 内容,因此我无法使用浮动 div 技术,并且需要通过 ajax/asp only 路线。我在网上所能找到的关于这个主题的只是人们在实现这个问题时遇到问题,但没有实际的工作示例代码。

我尝试使用 jtricks.com 上的 基于 jQuery 的浮动 div 菜单,但说明是对于 html 文件而不是 asp.net 文件,导致页面加载错误。

 <script type="text/javascript" src="specify script file URL here">  
 </script>  

 <div id="floatdiv" style="  
 position:absolute;  
 width:200px;height:50px;top:10px;right:10px;  
 padding:16px;background:#FFFFFF;  
 border:2px solid #2266AA;  
 z-index:100">  
 This is a floating javascript menu.  
 </div>  

    <script type="text/javascript">  
    floatingMenu.add('floatdiv',  
    {  
        // Represents distance from left or right browser window  
        // border depending upon property used. Only one should be  
        // specified.  
        // targetLeft: 0,  
        targetRight: 10,  

        // Represents distance from top or bottom browser window  
        // border depending upon property used. Only one should be  
        // specified.  
        targetTop: 10,  
        // targetBottom: 0,  

        // Uncomment one of those if you need centering on  
        // X- or Y- axis.  
        // centerX: true,  
        // centerY: true,  

        // Remove this one if you don't want snap effect  
        snap: true  
    });  
   </script>  

请提供一些通过 Ajax 在 TabContainer 或 DragPanel 中使用浮动 div 的示例代码。

谢谢! :)

Problem: I have a master page dictating the css, html, head, body content so I can't use the floating div technique and need to go trough the ajax/asp only route. All I have been able to find online on this subject is people having problems with implementing this but no actual working example code.

I tried using the jQuery based floating div menu off jtricks.com but the instructions were for an html file not a asp.net file and caused an error with the page load.

 <script type="text/javascript" src="specify script file URL here">  
 </script>  

 <div id="floatdiv" style="  
 position:absolute;  
 width:200px;height:50px;top:10px;right:10px;  
 padding:16px;background:#FFFFFF;  
 border:2px solid #2266AA;  
 z-index:100">  
 This is a floating javascript menu.  
 </div>  

    <script type="text/javascript">  
    floatingMenu.add('floatdiv',  
    {  
        // Represents distance from left or right browser window  
        // border depending upon property used. Only one should be  
        // specified.  
        // targetLeft: 0,  
        targetRight: 10,  

        // Represents distance from top or bottom browser window  
        // border depending upon property used. Only one should be  
        // specified.  
        targetTop: 10,  
        // targetBottom: 0,  

        // Uncomment one of those if you need centering on  
        // X- or Y- axis.  
        // centerX: true,  
        // centerY: true,  

        // Remove this one if you don't want snap effect  
        snap: true  
    });  
   </script>  

Please provide some sample code on using floating divs in TabContainer or DragPanel via Ajax.

Thanks! :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

强辩 2024-12-03 14:54:31

为了使基于 jquery 的浮动 div 菜单正常工作,我将 div 的代码放在 ASP 内容主部分中的 DynamicDataManager 控件之后和 ASP UpdatePanel 中:

 <asp:Content ID="main" ContentPlaceHolderID="main" Runat="Server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
       <ContentTemplate>
            <EditItemTemplate>

                <div id="floatdiv" style="position:absolute; width:200px; height:50px; top:10px; right:10px; padding:16px;background:#FFFFFF; border:2px solid #080808; z-index:100">
                <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Update" Text="Update" style="right:25px; padding:25px" updateDisabled = "updateDisabled +1; if (updateDisabled == 1) {return true;} else {this.disabled=true;return false;};" />
                <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
                </div>

我还添加了一个禁用更新按钮,以防止人们在数据库中创建 2 个重复记录:

<asp:DynamicEntity runat="server" Mode="Edit" OnInit="DynamicEntity_Init"/>

<script language="javascript" type="text/javascript"> var updateDisabled = 0; </script>
<asp:LinkButton runat="server" CommandName="Update" Text="Update" OnClientClick="updateDisabled = updateDisabled +1; if (updateDisabled == 1) {return true;} else {this.disabled=true;return false;};" />
<asp:LinkButton runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />

我将实际脚本放在 ASP 内容主标记内,但在更新面板之后:

 <script type="text/javascript">        
    floatingMenu.add('floatdiv',
    {
        // Represents distance from left or right browser window   
        targetRight: 10,

        // Represents distance from top or bottom browser window  
        targetTop: 10,

        snap: true
    });  
 </script>  

To make the jquery based floating div menu work, I put the code for the div within the ASP Content Main Section after the DynamicDataManager Control and in the ASP UpdatePanel:

 <asp:Content ID="main" ContentPlaceHolderID="main" Runat="Server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
       <ContentTemplate>
            <EditItemTemplate>

                <div id="floatdiv" style="position:absolute; width:200px; height:50px; top:10px; right:10px; padding:16px;background:#FFFFFF; border:2px solid #080808; z-index:100">
                <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Update" Text="Update" style="right:25px; padding:25px" updateDisabled = "updateDisabled +1; if (updateDisabled == 1) {return true;} else {this.disabled=true;return false;};" />
                <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
                </div>

I also added a disable update button to prevent people creating 2 duplicate records in the DB:

<asp:DynamicEntity runat="server" Mode="Edit" OnInit="DynamicEntity_Init"/>

<script language="javascript" type="text/javascript"> var updateDisabled = 0; </script>
<asp:LinkButton runat="server" CommandName="Update" Text="Update" OnClientClick="updateDisabled = updateDisabled +1; if (updateDisabled == 1) {return true;} else {this.disabled=true;return false;};" />
<asp:LinkButton runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />

I put the actual script within the ASP Content Main tag but after the Update Panel:

 <script type="text/javascript">        
    floatingMenu.add('floatdiv',
    {
        // Represents distance from left or right browser window   
        targetRight: 10,

        // Represents distance from top or bottom browser window  
        targetTop: 10,

        snap: true
    });  
 </script>  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文