Home Web Front-end HTML Tutorial When EasyUI needs to partially refresh the page in MVC4, the page deforms after load()! _html/css_WEB-ITnose

When EasyUI needs to partially refresh the page in MVC4, the page deforms after load()! _html/css_WEB-ITnose

Jun 24, 2016 pm 12:34 PM

Recently, when using MVC4 and EasUI, I encountered some problems that easily lead to interface deformation, and I struggled with them for a long time. However, when I found out where the problem was, I felt that in the end I had no idea about the concept of MVC4. Seize it, OK, show time. Part of the label loadAbout page of the Contact page in this example.

1. First, let’s restore the problem. I believe some friends will encounter it later. Load JS and CSS.

BundleConfig.cs under the App_Start file

1  bundles.Add(new ScriptBundle("~/bundles/jquery-easyui").Include(2                         "~/Content/jquery-easyui-1.3.4/jquery-easyui-min.js"));3 4  bundles.Add(new StyleBundle("~/Content/jquery-easyui-1.3.4/themes/default/css").Include("~/Content/jquery-easyui-1.3.4/themes/default/easyui.css"));
Copy after login

You need to pay attention to the above content when configuring: the name of jquery.easyui.min.js downloaded by default needs to be changed It is jquery-easyui-min.js, otherwise the loading will not be successful; secondly, pay special attention to the virtual path of the stylebundle, which must be XXX/Default/XXX. You need to reach the CSS directory, but the name can be customized; if it is XXX/Default If so, sorry, I can’t recognize the corresponding CSS.

2. Load the corresponding reference in the _Layout.cshtml page;

1   @Scripts.Render("~/bundles/jquery-easyui")<br />2  @Styles.Render("~/Content/css")
Copy after login

Use the link tag to place the style sheet in the document head, and in the script tag forward.

The reason is: In addition, the loading situation of placing the style at the bottom is: when the page loads gradually, the text is displayed first, followed by the picture. Finally, when the style sheet has been downloaded correctly, the rendered text and images will be redrawn with the new style. It's like in a grid shop, everything is laid out in order, but the boss says that this thing has to be placed this way, that way, and has to be rearranged one by one.

Place the script at the bottom

The reason is: placing the script at the top of the page will also cause page blocking and prevent the page from gradually rendering.

HTTP protocol 1.1 specification recommends that the browser download two components in parallel from each host. The number of parallel downloads depends on bandwidth and CPU. Excessive parallel downloads will also reduce performance. The advantages of parallel downloading are obvious. Components can be downloaded in parallel, but parallel downloading is disabled when downloading scripts to ensure that the scripts can be executed in the correct order. Because scripts cannot be downloaded in parallel, to avoid delays in downloading components, it is best to place the script at the bottom of the page.

3. The Controller code calls the page and uses PartialView, so that the framework will automatically filter out the styles and scripts of the master page and become a clean partial.

1   public PartialViewResult About()2         {3             ViewBag.Message = "Your app description page.";5             return PartialView();6         }
Copy after login

4. Contact page

 1 <section class="contact"> 2     <h2>日历 - Calendar</h2>   3     <div id="contantDiv" class="demo-info" style="margin-bottom: 10px">   4         <div class="demo-tip icon-tip"></div>   5         <div>单击选择日期</div>   6     </div>   7 </section> 8  9 <script type="text/javascript">10     function loadit() {11         $("#contantDiv").load("About");}12 </script>
Copy after login

5. About page

1  <div id="nihao" class="easyui-calendar" style="width: 180px; height: 180px;"></div>2  @* @Scripts.Render("~/bundles/jquery")*@ //此处是主要问题点,一不小心,就会让人很捉鸡。3  @Scripts.Render("~/bundles/jquery-easyui")
Copy after login

If you don’t add the tag If the red jquery reference is added, everything is normal;

If added, there seems to be a duplicate problem somewhere, as follows:

The reason for this problem is actually very simple. The controls of easyui need to be dynamically drawn, and the easyui.js loaded by the master page before will not be executed again after the Load() method is called, because that The product has been loaded once on the master page. This time, part of the page was redrawn using Ajax. Of course, I can't trouble anyone anymore. Sometimes if you feel uneasy and discordant, you will waste your time and effort. Looking back, you will find that the solution to the problem has long been waiting somewhere.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? Apr 05, 2025 am 06:15 AM

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

HTML, CSS, and JavaScript: Essential Tools for Web Developers HTML, CSS, and JavaScript: Essential Tools for Web Developers Apr 09, 2025 am 12:12 AM

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

How to distinguish between closing a browser tab and closing the entire browser using JavaScript? How to distinguish between closing a browser tab and closing the entire browser using JavaScript? Apr 04, 2025 pm 10:21 PM

How to distinguish between closing tabs and closing entire browser using JavaScript on your browser? During the daily use of the browser, users may...

See all articles