how i set the position of modalpopupextender to much any screen size?

HOUSSEM MAHJOUBI 286 Reputation points
2023-02-20T09:53:47.37+00:00

Hi admin

i have this code

  <ajaxToolkit:ModalPopupExtender ID="mpe" runat="server"
 TargetControlId="Button8" PopupControlID="ModalPanel2" 
 OkControlID="Button6" BackgroundCssClass="modalBackground2" X="1100" Y="190" />

i want to change the value in x and y accordinly the width of screen

please help

Developer technologies | VB
Developer technologies | ASP.NET | Other
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 30,191 Reputation points Microsoft External Staff
    2023-02-21T05:33:42.8166667+00:00

    Hi @HOUSSEM MAHJOUBI ,

    You can do it via javascript.

    You can use set_X()and set_Y() to set coordinates.

     <script type="text/javascript">
            function setPopup() {
                var pop = $find("mpe");
                var scr = screen.width;
                if (pop != null) {
                    
                    pop.set_X(scr * 0.4);
                    pop.set_Y(scr * 0.2);
                   
                }
            }
        </script>
    
    <asp:Button ID="Button8" runat="server" Text="Show Modal Popup" OnClientClick="setPopup()" />
            <ajaxToolkit:ModalPopupExtender ID="mpe" runat="server"
                TargetControlID="Button8" PopupControlID="ModalPanel2"
                OkControlID="Button6" BackgroundCssClass="modalBackground2" />
            <asp:Panel ID="ModalPanel2" runat="server" CssClass="modalPopup" align="center" Style="display: none">
                This is an ASP.Net AJAX ModalPopupExtender Example<br />
                <asp:Button ID="Button6" runat="server" Text="Close" />
            </asp:Panel>
    

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.