How to Deploy ASP.NET Core DOCX Editor for Mobile
27 Aug 20261 minute to read
DOCX Editor component for mobile
At present, the ASP.NET Core DOCX Editor (Document Editor) component is not responsive on mobile, and the editing functionalities are not ensured in mobile browsers. However, it works properly as a document viewer in mobile browsers. Hence, it is recommended to switch the DOCX Editor component to read-only mode in mobile browsers. Also, invoke the fitPage method with the FitPageWidth parameter in the document change event to display one full page by adjusting the zoom factor.
<ejs-documenteditorcontainer id="container" enableToolbar=true documentChange="onDocumentChange" height="590px">
</ejs-documenteditorcontainer>
<script>
function onDocumentChange() {
var container = document.getElementById("container").ej2_instances[0];
//To detect the device
var isMobileDevice = /Android|Windows Phone|webOS/i.test(navigator.userAgent);
if (isMobileDevice) {
container.restrictEditing = true;
setTimeout(() => {
container.documentEditor.fitPage("FitPageWidth");
}, 50);
}
else {
container.restrictEditing = false;
}
}
</script>You can use the
restrictEditingproperty in the DocumentEditorContainer and theisReadOnlyproperty in the DocumentEditor, based on your requirement, to change the component to read-only mode.