It looks like you are trying to position the modal popup extender based on the screen size, but that may not work well on all devices or screen resolutions. Instead, you could try positioning the popup relative to a parent element, such as the button or dropdownlist that triggers it.
Here is an example of how you could position the modal popup extender next to a dropdownlist, using jQuery:
- Add the jQuery library to your page, if it is not already included:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
- Add an
onclick
event to the dropdownlist, to show the modal popup extender and position it next to the dropdownlist:
<asp:DropDownList ID="DropDownList5" runat="server" Height="16px" Width="272px"
AutoPostBack="True" onchange="$find('mpe').show(); positionPopup();">
</asp:DropDownList>
- Define a
positionPopup()
function in JavaScript, to position the popup relative to the dropdownlist:
<script type="text/javascript">
function positionPopup() {
var pop = $find("mpe");
var ddl = $("#<%= DropDownList5.ClientID %>");
if (pop != null && ddl != null) {
var ddlOffset = ddl.offset();
var ddlWidth = ddl.outerWidth();
var popWidth = pop.get_PopupControlID().offsetWidth;
pop.set_X(ddlOffset.left + ddlWidth);
pop.set_Y(ddlOffset.top);
}
}
</script>
This function gets the position and width of the dropdownlist, and positions the popup next to it by setting the X and Y properties of the modal popup extender.
Note that you may need to adjust the positioning and sizing of the popup based on your specific requirements and CSS styles.
I hope this helps!
Please, if this answer is helpful, click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please let me know.