Articles in this section
Category / Section

How to avoid the Flashing or popping effect in JavaScript Platforms?

2 mins read

How to avoid the Flashing or popping effect during control rendering in ASP and MVC platforms

 

Cause:

In our ASP.NET and ASP.NET MVC platform, the controls are rendered using tag helpers. During rendering of our controls, these tag helpers get serialized to generate a script which actually renders the control using JavaScript. Since our controls are JavaScript based controls. Now during this process, there is a delay between the tag helpers being serialized and controls being rendered using the generated script. This is delay causes the control to appear flashing or popping from native HTML elements.

 

Solution:

To avoid this flashing or popping from HTML elements effect, a new <div> element can be added to contain the control, with its CSS visibility property set to hidden. Now the control will not be visible in DOM during rendering. Once the control render completes, the create event of the same control can be used to set the visibility property of the <div> element to visible from hidden. Thus, avoiding the controls from being flashing from the HTML elements.

 

Refer to the following example in the ASP.NET WebForms platform,

[ASP]

<div id="container" style="visibility:hidden;">
    <ej:DatePicker runat="server" ID="datepick" Width="100%"></ej:DatePicker>
    <br />
    <ej:NumericTextBox ID="numeric" Name="numeric" runat="server" width="100%" />
    <br />
    <ej:DropDownList ID="selectCar" runat="server" WatermarkText="Select a car" ClientSideOnCreate="oncreate" Width="100%">
        <Items>
            <ej:DropDownListItem Text="Audi A4" Value="Audi A4"></ej:DropDownListItem>
            <ej:DropDownListItem Text="Audi A5" Value="Audi A5"></ej:DropDownListItem>
            <ej:DropDownListItem Text="Audi A6" Value="Audi A6"></ej:DropDownListItem>
            <ej:DropDownListItem Text="Audi A7" Value="Audi A7"></ej:DropDownListItem>
            <ej:DropDownListItem Text="Audi A8" Value="Audi A8"></ej:DropDownListItem>
        </Items>
    </ej:DropDownList>
</div>
<script>
    function oncreate() {
        $("#container").css("visibility", "visible");
    }
</script>

 

Sample link

Note:

Make sure that the Create event is bound to the last Syncfusion control in the page for an optimal experience.

 

Refer to the following example in the ASP.NET MVC platform,

<div id="container" style="visibility:hidden;">
    @Html.EJ().DatePicker("DatePick").Width("100%")
    <br />
    @Html.EJ().NumericTextbox("numeric").Width("100%")
    <br />
    @Html.EJ().DropDownList("selectCar").TargetID("carsList").Width("100%").WatermarkText("Select Value").ClientSideEvents(e => e.Create("oncreate"))
    <div id="carsList">
        <ul>
            <li>Audi A4</li>
            <li>Audi A5</li>
            <li>Audi A6</li>
            <li>Audi A7</li>
            <li>Audi A8</li>
        </ul>
    </div>
</div>
<script>
    function oncreate() {
        $("#container").css("visibility", "visible");
    }
</script>

 

Sample link

Note:

Make sure that the Create event is bound to the last Syncfusion control in the page for an optimal experience.

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied