AjaxControlToolKit ModalPopupExtender Drag snap back to center

时光总嘲笑我的痴心妄想 提交于 2019-12-11 11:03:06

问题


I am using ModalPopupExtender of AjaxControlToolKit 4.0 (ASP.NET 4.0), every thing working fine, when I drag ModalPopup it is dragging, but the problem is that it is snaping back to its original location(Center). The same code is working on: http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/ModalPopup/ModalPopup.aspx

I have search about this issue but all solutions are given by using external Java script code, but what can be the mistake on following code while the same code working on ASP.NET example page. (From where I copied the same code)

This is my code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="AjaxToolKitTest4.WebForm3" %>

<!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">
    <title>Hello</title>
    <link href="style.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
        <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager>

        <div>
            <%--Start LinkButton to Show Modal Popup Form--%>
            <asp:LinkButton ID="lnkAddForm" Text="Insert" runat="server" OnClick="lnkAddForm_Click"></asp:LinkButton>
            <%--End LinkButton to Show Modal Popup Form--%>

            <%--Start Panel for Modal Popup Form--%>
            <asp:Panel ID="programmaticPopup"  runat="server" CssClass="modalPopup" Style="display: none; width: 350px; padding: 10px;">                
                <asp:Panel runat="Server" ID="programmaticPopupDragHandle" Style="cursor: move; width:100%; background-color: #DDDDDD; border: solid 1px Gray; color: Black; text-align: center;">
                    Title Bar
                </asp:Panel>
                    Content of Modal Form
            </asp:Panel>
            <%--End Panel for Modal Popup Form--%>

            <%-- Start AjaxToolKit ModalPopupExtender for Panel  --%>
            <asp:Button runat="server" ID="hiddenTargetControlForModalPopup" Style="display: none" />
            <ajaxToolkit:ModalPopupExtender 
                ID="programmaticModalPopup"                 
                BehaviorID="programmaticModalPopupBehavior"
                TargetControlID="hiddenTargetControlForModalPopup" 
                PopupControlID="programmaticPopup"
                BackgroundCssClass="modalBackground" 
                DropShadow="false" 
                PopupDragHandleControlID="programmaticPopupDragHandle"
                RepositionMode="RepositionOnWindowScroll"
                runat="server">
            </ajaxToolkit:ModalPopupExtender>
            <%-- End AjaxToolKit ModalPopupExtender for Panel  --%>
        </div>

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

回答1:


The modal popup uses the body of the form for dragging. If the body's height is not properly set, the dragging will not work properly.

Set the following CSS styles and dragging should work.

html, body
{
    margin: 0;
    padding: 0;
    height: 100%;
}


来源:https://stackoverflow.com/questions/21955471/ajaxcontroltoolkit-modalpopupextender-drag-snap-back-to-center

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!