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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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)

What are the best practices for cross-browser compatibility in HTML5? What are the best practices for cross-browser compatibility in HTML5? Mar 17, 2025 pm 12:20 PM

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

How do I use HTML5 form validation attributes to validate user input? How do I use HTML5 form validation attributes to validate user input? Mar 17, 2025 pm 12:27 PM

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

What is the viewport meta tag? Why is it important for responsive design? What is the viewport meta tag? Why is it important for responsive design? Mar 20, 2025 pm 05:56 PM

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

The article discusses the &lt;iframe&gt; tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

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.

See all articles