Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC 2 - I have a control that uses a lot of HTML. How do I improve the performance?
    primarykey
    data
    text
    <p>I am developing a product with users who up until now have been using Excel and they want my MVC application to be similar to that. They like the visual impact of seeing annual leave, so I have developed a scrollable table which looks like this; <img src="https://i.stack.imgur.com/ydUYS.jpg" alt="enter image description here"></p> <p>The table is going to be about 300 cells across, and I might have 15 people to display this information, so you can see this could get very large indeed. I mentioned to them before I built the control that there would be performance issues. But now they like the product and want it to load more quickly. I would not be surprised if the code I wrote could be refactored. No doubt it could be written better anyway, and maybe performance can be improved as well, so I will show you that. However I suspect the real problem is too much HTML. What are my other options? I am not yet familiar with Silverlight or HTML5, although I am happy to look into it if someone can provide me with some good links. My webpage has this markup;</p> <pre><code>&lt;% if (Model.cvm != null &amp;&amp; Model.cvm.Lines != null &amp;&amp; Model.cvm.Lines.Count &gt; 0) { %&gt; &lt;table cellpadding="0" cellspacing="0"&gt; &lt;tr&gt; &lt;td&gt; &lt;table cellpadding="0" cellspacing="0" id="TeamNames"&gt;&lt;!-- Table to display names of team members --&gt; &lt;tr&gt; &lt;td style="height:65px"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;% foreach (SHP.Models.CalendarViewModel.CalendarLine cl in Model.cvm.Lines) {%&gt; &lt;tr&gt; &lt;td align="right"&gt;&lt;%: cl.Name%&gt;&lt;/td&gt; &lt;/tr&gt; &lt;%} %&gt; &lt;/table&gt; &lt;/td&gt; &lt;td&gt; &lt;div id="pageWidthCalendar"&gt;&lt;!-- Table to display a scrollable grid of the annual leave calendar --&gt; &lt;table id="ScheduledLeaveCalendar"&gt; &lt;%: Html.DisplayFor(x =&gt; x.cvm.Header1)%&gt; &lt;%: Html.DisplayFor(x =&gt; x.cvm.Header2)%&gt; &lt;%: Html.DisplayFor(x =&gt; x.cvm.Header3)%&gt; &lt;%: Html.DisplayFor(x =&gt; x.cvm.Lines)%&gt; &lt;/table&gt; &lt;/div&gt;&lt;!-- pageWidthCalendar - puts scrollbars on the calendar control --&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>My Calendar Lines Display Template has this markup;</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;SHP.Models.CalendarViewModel+CalendarLine&gt;" %&gt; &lt;%@ Import Namespace="SHP.WebUI.HtmlHelpers" %&gt; &lt;%@ Import Namespace="SHP.Models" %&gt; &lt;tr&gt; &lt;% foreach (var item in Model.HtmlCellCollection) { %&gt; &lt;%: Html.CalendarCellClass(item)%&gt; &lt;% } %&gt; &lt;/tr&gt; </code></pre> <p>The other display templates are similar.</p> <p>My CalendarCellClass helper method looks like;</p> <pre><code> public static MvcHtmlString CalendarCellClass(this HtmlHelper helper, CalendarViewModel.CalendarCell _cell) { TagBuilder td_Outer = new TagBuilder("td"); if (_cell.MorningOnlyFlag == true || _cell.AfternoonOnlyFlag == true) { td_Outer.InnerHtml = GetHalfDayTable(_cell); } else td_Outer.MergeAttribute("class", _cell.HtmlCellClass); return MvcHtmlString.Create(td_Outer.ToString()); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload