ASP.NET和更新面板

时间:2015-10-20 16:13:19

标签: asp.net updatepanel

使用主页和详细信息页面,我的ScriptManager中有MasterPage,详细信息页中有UpdatePanel

UpdatePanel刷新计时器刻度(每秒)

UpdatePanel中是一个图像,它是HMI过程的实时视图。

(顺便说一句,使用Chrome)"通常"一切正常 - 图像被刷新以提供HMI的合理的最新视图,并且没有闪烁,但是整个页面经常会因为整体刷新而不寒而栗。

背后没有任何逻辑。该页面肯定会进行全面刷新 - MasterPage中包含的顶部菜单栏也会刷新。

这"颤抖"可能会持续几秒钟(页面每秒刷新一次),然后平静下来,以便稍后重复。

有人可以向我解释可能发生的事情吗?

由于

P.S。下面的代码和屏幕截图显示了闪烁的原因 - 由于某种原因,图像不会瞬间显示。

这是刷新前屏幕的显示方式(注意标题栏中的时间)before screen refresh

当它闪烁时,主图像丢失:Image missing here

然后一瞬间(不到一秒钟)出现正确的图像(注意标题栏中的时间是一秒钟之后)。

correct image 现在这不是因为网页没有被要求显示图像 - 如果没有从WCF服务返回图像,则显示默认图像。出于某种原因,网页根本不显示实际图像。请求网页每秒刷新一次,但闪烁(它非常非常快地发生)表示在刷新之间,整个页面(包括顶部导航栏)被刷新(减去图像)。所以看来,页面每1/2秒刷新一次。

这种情况经常发生在一些PC上(随机x秒)。我正在远程机器上观看该页面,这并没有错过任何一个节拍,而我的电脑经常会出现震动。

此外,图像总是在I.E.中闪烁尽管有部分渲染。

代码示例:

母版页



<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="PracticonWebMimic.SiteMaster" %>

<!DOCTYPE html>

<html lang="en">
<head runat="server">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title><%: Page.Title %> - Practicon Factory View</title>
    
    <asp:PlaceHolder runat="server">
        <%: Scripts.Render("~/bundles/modernizr") %>
    </asp:PlaceHolder>
    <webopt:bundlereference runat="server" path="~/Content/css" />
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />

</head>
<body>
    <form runat="server">
       <asp:ScriptManager runat="server" EnablePartialRendering="true">
            <Scripts>
                <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%>
                <%--Framework Scripts--%>
                <asp:ScriptReference Name="jquery" />
                <asp:ScriptReference Name="bootstrap" />
                <asp:ScriptReference Name="respond" />
                <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
                <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
                <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
                <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
                <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
                <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
                <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
                <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
                <%--Site Scripts--%>
            </Scripts>
        </asp:ScriptManager>

        <div class="navbar navbar-inverse navbar-fixed-top">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" runat="server" href="~/">Practicon Factory View</a>
                </div>
                <div class="navbar-collapse collapse">
                    <ul class="nav navbar-nav">
                        <li><a runat="server" href="~/">Home</a></li>
                        <li><a runat="server" id="mimicList" visible="false"
                                 href="~/RestrictedAccess/MimicList.aspx">Views</a></li>
                        <li><a runat="server" id="mimicListArchive" visible="false"
                                 href="~/RestrictedAccess/MimicList.aspx?archive=<%= DateTime.Now.Ticks %>">Archive Views</a></li>
                       <!-- <li><a runat="server" href="~/About">About</a></li>
                        <li><a runat="server" href="~/Contact">Contact</a></li> -->
                    </ul>
                    <asp:LoginView runat="server" ViewStateMode="Disabled">
                        <AnonymousTemplate>
                            <ul class="nav navbar-nav navbar-right">
                              <!--  <li><a runat="server" href="~/Account/Register">Register</a></li> -->
                                <li><a runat="server" href="~/Account/Login">Log in</a></li>
                            </ul>
                        </AnonymousTemplate>
                        <LoggedInTemplate>
                            <ul class="nav navbar-nav navbar-right">
                                <li>
                                    <asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" />
                                </li>
                            </ul>
                        </LoggedInTemplate>
                    </asp:LoginView>
                </div>
            </div>
        </div>

        <div class="container body-content">
            <asp:ContentPlaceHolder ID="MainContent" runat="server">

            </asp:ContentPlaceHolder>
            <hr />
            <footer>
                <p>&copy; <%: DateTime.Now.Year %> - Practicon Factory View</p>
                <asp:Label  id="lbError" runat="server" Text=""></asp:Label>
            </footer>
        </div>
    </form>
</body>
</html>
&#13;
&#13;
&#13;

详细信息页面

&#13;
&#13;
<%@ Page Title="Factory View" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="MimicDetails.aspx.cs" Inherits="PracticonWebMimic.MimicDetails" %>

<%@ Register Assembly="TimePicker" Namespace="MKB.TimePicker" TagPrefix="MKB" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
   
     <link href="/Content/PrBlueTable.css" rel="stylesheet" type="text/css" />
   
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>

    <script src="//cdn.jsdelivr.net/jquery.ui.timepicker.addon/1.4.5/jquery-ui-sliderAccess.js"></script>
    <link rel="stylesheet" href="//cdn.jsdelivr.net/jquery.ui.timepicker.addon/1.4.5/jquery-ui-timepicker-addon.css">
    <script src="//cdn.jsdelivr.net/jquery.ui.timepicker.addon/1.4.5/jquery-ui-timepicker-addon.js"></script>
      <script type="text/javascript">
        $(document).ready(function () {

            var prm = Sys.WebForms.PageRequestManager.getInstance();
            prm.add_initializeRequest(InitializeRequest);
            prm.add_endRequest(EndRequest);
        });

        function InitializeRequest(sender, args) { }
        function EndRequest(sender, args) {
            // after update occur on UpdatePanel re-init the DatePicker 
            $('.ui-datepicker').datetimepicker({
                inline: true,
                showOtherMonths: true,
                showOn: 'focus',
                showButtonPanel : true,
                dateFormat: "dd/mm/yy",
                nextText: ">>",
                prevText : "<<",
                timeFormat: "HH:mm:ss",
                dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
            });
        }
</script>

    <asp:FormView ID="mimicDetail" runat="server"
            ItemType="PracticonWebMimic.Models.Mimic" SelectMethod ="GetMimic"
            RenderOuterTable="false">

            <ItemTemplate>
                    <div>
                            <h2>
                                <asp:Label ID="lblActive_MimicDetails" runat="server"  Visible="true"/>

                                <%#:Item.MimicName %>


                            </h2>
                          
                           
                    </div>
                    <br />
                  <table>
                              <tr>  
                                    <td>
                                            <asp:UpdatePanel ID="upMimic_MimicDetails" runat="server" UpdateMode="Conditional"  ChildrenAsTriggers="true">
                                                 <ContentTemplate>
                                                        <asp:Label ID="lbConditionName_MimicDetails" runat="server" CssClass="btn-primary" Visible="False"/>
                                                      <asp:Panel ID="pnMimic" runat="server" style="margin-bottom: 2px">
                                                                     <%-- Mimic Image ------------------------------------------------------------------------------------------------------------------------------- --%>
                                                                     <img id="imMimic_MimicDetails" runat="server" src="./Assets/Images/running.jpg"/>
                                                                    
                                                     </asp:Panel>
                                                     <br />
                                                     <h4><asp:Label  id="lbDirection_MimicDetails" runat="server" CssClass="btn-default"  Text=""></asp:Label> </h4>
                                                           <%-- Action Buttons starts here ------------------------------------------------------------------------------------------------------------------------------- --%>
                                                        <asp:Table class="tbActionButtonBar"  runat="server"  CssClass="prTable">
                                                                    <asp:TableRow >
                                                                        <asp:TableCell>

                                                                                <asp:Table class="tbActionButtonBar"  runat="server">

                                                                                        <asp:TableRow >
                                                                                                <asp:TableCell >
                                                                                                        <asp:ImageButton id="btnRestart_MimicDetails" runat="server" onclick="imgRestart_Click" Width="50" ToolTip="Restart playback from beginning." />
                                                                                                        <asp:ImageButton id="btnStop_MimicDetails" runat="server"  onclick="imgStop_Click" Width="50" ToolTip="Stop playback and show the LIVE Factory View." />
                                                                                                        <asp:ImageButton id="btnRewind_MimicDetails" runat="server"  onclick="imgRewind_Click" Width="50" ToolTip="Rewind the animation" />
                                                                                                        <asp:ImageButton id="btnPlay_MimicDetails" runat="server" onclick="imgPlay_Click" Width="50" ToolTip="Start playback of animation from current time." />
                                                                                                        <asp:ImageButton id="btnFForward_MimicDetails" runat="server" onclick="imgFForward_Click" Width="50" ToolTip="Fast-forward through animation." />
                                                                                                        <asp:ImageButton id="btnPause_MimicDetails" runat="server" onclick="imgPause_Click" Width="50" ToolTip="Pause playback of animation." />
                                                                                                                                    
                                                                                                </asp:TableCell>

                                                                                                <asp:TableCell> 
                                                                                                      <asp:ImageButton id="btnTrends_MimicDetails" runat="server"  Width="50" ToolTip="Show the Trends for the current Factory View" />
                                                                                                 </asp:TableCell>

                                                                                                 <asp:TableCell>
                                                                                                     <asp:ImageButton id="btnConditionMonitoring_MimicDetails" runat="server"  Width="50" ToolTip="View Condition Monitoring for this Factory View." />
                                                                                                </asp:TableCell>
                                                                                            
                                                                                                <asp:TableCell>
                                                                                                            <h5><asp:Label ID="lbStatus_MimicDetails" runat="server"  CssClass="btn-default" Text=""></asp:Label></h5>
                                                                                                </asp:TableCell>
                                                                                            
                                                                                                 <asp:TableCell>
                                                                                                            <h5><asp:Label ID="lbSession_MimicDetails" runat="server"  CssClass="btn-default" Text=""></asp:Label></h5>
                                                                                                </asp:TableCell>

                                                                                                <asp:TableCell>
                                                                                                    <asp:Button ID="btnSession_MimicDetails" runat="server" Text="Reconnect" CssClass="btn-default" onclick="btnSession_TrendDetails_Click"> </asp:button>
                                                                                                </asp:TableCell >


                                                                                        </asp:TableRow>
                                                                                </asp:Table>
                                                                 </asp:TableCell >

                                                           </asp:TableRow>

                                                        </asp:Table>
                                                     <%-- DateTime control starts here ------------------------------------------------------------------------------------------------------------------------------- --%>
                                                     <asp:Table  id="tbActionDateBar_MimicDetails" runat="server" CssClass="prBlueTable">
                                                                    <asp:TableRow>
                                                                            <asp:TableCell >
                                                                                    <asp:Label Text="FROM   : " runat="server" id="lbFrom_MimicDetails"></asp:Label>
                                                                                    <asp:TextBox type="text" id="txtStartDate_MimicDetails" runat="server" OnTextChanged="txtStartDate_MimicDetails_TextChanged" />
                                                                                    <asp:Label  id="lbFromDate_MimicDetails" runat="server"/>
                                                                            </asp:TableCell><asp:TableCell>
                                                                                        <asp:CheckBox Text="  End date? " runat="server" id="chkEndDate_MimicDetails" AutoPostBack="true" OnCheckedChanged="chkEnableEndDate_CheckedChanged"></asp:CheckBox>
                                                                            </asp:TableCell><asp:TableCell >
                                                                                        <asp:Label Text="TO    : " runat="server" ID ="lbTo_MimicDetails"></asp:Label>
                                                                            </asp:TableCell><asp:TableCell>
                                                                                        <asp:TextBox type="text" id="txtEndDate_MimicDetails" runat="server" OnTextChanged="txtEndDate_MimicDetails_TextChanged"/>
                                                                                        <asp:Label  id="lbEndDate_MimicDetails" runat="server"/>
                                                                            </asp:TableCell><asp:TableCell>
                                                                                        <asp:CheckBox Text="Auto-restart?" runat="server" id="chkAutoRewind_MimicDetails"  OnCheckedChanged="chkAutorewind_MimicDetails_CheckedChanged"></asp:CheckBox>
                                                                            </asp:TableCell></asp:TableRow></asp:Table><asp:Timer ID="tmrMimic_MimicDetails" runat="server" Interval="1000" OnTick="MimicTimer_Tick"> </asp:Timer>
                                                                
                                                     <asp:Label ID="lbServiceResponse_MimicDetails" runat="server" CssClass="btn-default"  Text="" ></asp:Label><br />
                                                     
                                                     <asp:Label  id="lbRefreshRequested_MimicDetails" runat="server" Text=""></asp:Label>
                                                     
                                                     <asp:Label  id="lbRefreshed_MimicDetails" runat="server" Text=""></asp:Label><br />
                                                     
                                                     <asp:Label ID="lbServiceAddress_MimicDetails" runat="server" Text=""></asp:Label><br/>
                                                     
                                                     <asp:Label ID="lbError_MimicDetails" runat="server" Text=""></asp:Label>

                                                     <asp:Label ID="lbSessionID_MimicDetails" runat="server" Text=""></asp:Label>


                                                 </ContentTemplate>
                                                <Triggers>
                                                            <asp:AsyncPostBackTrigger ControlID="tmrMimic_MimicDetails" EventName="Tick"/>
                                                   </Triggers>
                                            </asp:UpdatePanel>
                                    </td>
                            </tr>
                </table>
      
            </ItemTemplate>
    </asp:FormView>

</asp:Content>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:3)

在经历了令人难以置信的几天试图对此进行排序之后,我偶然发现了一个适用于Chrome,Firefox和I.E的解决方案。

解决方案是在浏览器中禁用硬件加速

我现在需要去额头上贴上一些令人讨厌的瘀伤。

希望这有助于某人。

相关问题