- Home
- Forum
- ASP.NET Web Forms
- Dialog Pop up Position
Dialog Pop up Position
Hi Chong,
Thanks for your update.
We would like to let you know that Dialog popup will be
appeared in the center of the browser window by default. We
have used $(window).scroll() function to set the Dialog popup in fixed
position. The Css property position is used here to set Dialog’s
position. If you set this property as fixed, then Dialog popup will
appear in the middle of the page even you scroll. Refer the below work around to display Dialog popup in center of the browser window.
<script>
$(window).scroll(function () {
$("#dialogposition_wrapper").css({ 'position': 'fixed' });
});
script>
Note: Here dialogposition is Id of the Dialog control
Please find the attached sample.
Regards,
Jaganprakash
Attachment: Dialog_position_66a3c9a0.zip
Hi Chong,
Thanks for your update.
We have modified the code as per your requirements. We have set the position of the Dialog box with respect to the scroll bar position in positioned() function. Initially Dialog box will be in the middle of the page and the position of the scroll bar is (0,0). Position of the scroll bar is calculated and added with the position of the Dialog while scrolling. Therefore if the page is scrolled, then the Dialog will also be scrolled. We have used position property to set X and Y value to Dialog box. The reported issues are resolved as follows.
Now when you move the Dialog box, then scroll the page, It will automatically appear in the middle of the page. Because positioned() is called inside $(window).scroll() function.
When the page is already scrolled halfway, then the dialog box is triggered to show, X and Y values should be set to Dialog box accordingly. We have used a Button to trigger the Dialog box. Close the Dialog box and click that button to open the Dialog box again. Now it will appear at the middle of the page even the page was scrolled halfway. Because positioned() function is called in the click() function. Refer the following code.
[ASPX]
<ej:Dialog ID="dialogposition" runat="server" Title="Dialog">
<ej:ToggleButton ID="ToggleButton1" runat="server" DefaultText="Dialog" ClientSideOnClick="click">ej:ToggleButton>
<script>
function click() {
var dialogObj = $("#dialogposition").data("ejDialog");
dialogObj.open();
positioned();
}
function positioned() {
var windowpostop = $(window).scrollTop();
var windowposleft = $(window).scrollLeft();
$("#dialogposition").ejDialog({ position: { X: windowposleft + 553, Y: windowpostop + 282 } });
}
$(window).scroll(function () {
positioned();
});
script>
Please find the attached sample.
Regards,
Jaganprakash
Attachment: Dialog_position_b61f62c9.zip
Hi Chong Yee Mei
Thanks for the Update.
Please let us know if you have any other
queries.
Regards,
Rajaveni
[ASPX]
<ej:Dialog ID="dialogposition" runat="server" Title="Dialog">
<ej:ToggleButton ID="ToggleButton1" runat="server" DefaultText="Dialog" ClientSideOnClick="click">ej:ToggleButton>
<script>
function click() {
var dialogObj = $("#dialogposition").data("ejDialog");
dialogObj.open();
positioned();
}
function positioned() {
var windowpostop = $(window).scrollTop();
var windowposleft = $(window).scrollLeft();
$("#dialogposition").ejDialog({ position: { X: windowposleft + 553, Y: windowpostop + 282 } });
}
$(window).scroll(function () {
positioned();
});
</script>
my code looks like this.
<div id="userInfoPopup" >
@{Html.EJ().Dialog("ViewUserInfo").Title("Information").Items(data =>
{
data.ContentTemplate(@<div style="margin: 5px 14px;">@Html.Partial("Information/UserInformation")</div>);
}).ShowRoundedCorner(true).ShowOnInit(false).EnableModal(true).EnableResize(false).Width(450).Render();}
</div>
Thank you for contacting Syncfusion support.
The solution provided to position the Dialog in the center window for ASP.NET can be used for ASP.NET MVC as well. We have set the position of the Dialog box with respect to the scroll bar position in positioned() function. Initially Dialog box will be in the middle of the page and the position of the scroll bar is (0,0). When you scroll the page, It will automatically position to the middle of the page since positioned() is called inside $(window).scroll() function. Replace the ID of the Dialog control in script and implement the positioned method where you open the Dialog popup window. Also we are unable to find the code on where the Dialog pop up is opened in the shared script code WaitingPopup is shown. If this is not your requirement please explain your requirement on positioning MVC control.
To position the dialog based on your shared code we have prepared a sample using Dialog in MVC and it can be downloaded from the link below:
http://www.syncfusion.com/downloads/support/forum/117274/ze/Dialog_f117274778376744
Please let us know if you have any other queries.
Regards,
Ezhil S
Thanks for sharing your solution to set Dialog position to center.
This will help someone looking for this behavior.
Please get back to us if you have any other queries.
Regards,
Ezhil S
- 11 Replies
- 5 Participants
-
CY Chong Yee Mei
- Sep 22, 2014 07:34 AM UTC
- Jul 7, 2015 12:49 PM UTC