如何停止回发内容页面 [英] How to stop postback content page

查看:63
本文介绍了如何停止回发内容页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在vs2010工作。在应用程序中,我在Web用户控件中使用计时器,当计时器执行内容页面时,该计时器被放置在母版页上。如何在定时器执行时停止回发内容页面。我也在wb用户控件中使用updatepanel。

这里是网络用户控制代码



i am working at vs2010. In an application i am using timer in web user control which is placed on master page when timer execute the content page is postback. how can i stop postback of content page when timer execute. i also use updatepanel in wb user control.
here is web user control code

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Notifications.ascx.cs" Inherits="GUI_Notifications" %>
<style type="text/css">
    .style1
    {
        width: 200px;
    }
</style>
<asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="20000">
                        </asp:Timer>
                        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
                <div style="height:auto; width:199px;">
                        <table id="table" class="table1"  runat="server"

                        style="border-top-style: none; border-right-style: none;
                        border-left-style: none; background-color: whitesmoke; border-bottom-style: none">
                        <tr>
                            <td id="ddl_dropdown" class="td_d"  runat="server">
                                <asp:DropDownList ID="ddl_Org" runat="server" CssClass="combo" 

                                    Width="190px" onselectedindexchanged="ddl_Org_SelectedIndexChanged" 

                                    AutoPostBack="True" Enabled="False">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td id="td_ExMat" class="td_d"  runat="server">
                                <div id="noti_Container" class="style4">
                                <asp:HyperLink ID="HyperLink5" runat="server" style="font-weight: 700"

                                    ToolTip="Gate Pass Approval" NavigateUrl="~/GUI/FmExtraMaterial.aspx" 

                                    CssClass="lbl">Extra Material</asp:HyperLink>
                                    <div id="div_ExMat" class="noti_bubble"  runat="server" visible="false" style="right: 10px" >
                                    <asp:Label ID="Label3" runat="server"></asp:Label></div>
                                    </div>
                                </td>
                        </tr>
                        <tr>
                            <td id="td_VehMaints" class="td_d"  runat="server">
                             <div id="noti_Container" class="style4">
                                <asp:HyperLink ID="HyperLink6" runat="server" style="font-weight: 700"

                                    ToolTip="Vehicle Maintenance Approval" NavigateUrl="~/GUI/FMVehicleMainApproval.aspx" 

                                    CssClass="lbl">Vehicle Maintenance Approval</asp:HyperLink>
                                    <div id="div_VehMaintApp" class="noti_bubble"  runat="server" visible="false" style="right: 10px" >
                                    <asp:Label ID="lbl_VehMaintApp" runat="server"></asp:Label></div>
                                    </div>
                                </td>
                        </tr>
                        <tr>
                            <td id="td_GatePass" class="td_d"  runat="server">
                            <div id="noti_Container">
                            <asp:HyperLink ID="HyperLink2" runat="server" style="font-weight: 700"

                                    ToolTip="Gate Pass Approval" NavigateUrl="~/GUI/wfrmGatePass.aspx" 

                                    CssClass="lbl">Gate Pass Approval</asp:HyperLink>
                                    <div id="div_Req" class="noti_bubble"  runat="server" visible="false" style="right: 10px">
                                    <asp:Label ID="Gatepass" runat="server"></asp:Label></div>
                                    </div>
                            </td>
                        </tr>
                        <tr>
                            <td id="td_PurApp" class="td_d"  runat="server">
                            <div id="noti_Container" class="style4">
                            <asp:HyperLink ID="HyperLink1" runat="server" style="font-weight: 700"

                                    ToolTip="Purchase Approval" NavigateUrl="~/GUI/wfrmPurchApproval.aspx" 

                                    CssClass="lbl">Purchase Approval</asp:HyperLink>
                                    <div id="div2" class="noti_bubble"  runat="server" visible="false" style="right: 10px">
                                    <asp:Label ID="PurApp" runat="server"></asp:Label></div>
                                    </div>

                            </td>
                        </tr>
                        <tr>
                            <td id="td_OT" class="td_d"  runat="server">
                            <div id="noti_Container">
                            <asp:HyperLink ID="HyperLink3" runat="server" style="font-weight: 700"

                                    ToolTip="Over Time Schedule Approval" 

                                    NavigateUrl="~/GUI/fmOvertimeScheduleApp.aspx" CssClass="lbl">Over Time Schedule Approval</asp:HyperLink>
                                     <div id="div1" class="noti_bubble"  runat="server" visible="false" style="right: 10px">
                                    <asp:Label ID="OTSchedule" runat="server"></asp:Label></div>
                                    </div>
                            </td>
                        </tr>
                        <tr>
                            <td id="td_GenReq" class="td_d"  runat="server">
                            <div id="noti_Container" class="style5">
                            <asp:HyperLink ID="HyperLink4" runat="server" style="font-weight: 700"

                                    ToolTip="General Request Approval" 

                                    NavigateUrl="~/GUI/fmGeneralRequisitionApp.aspx" CssClass="lbl">General Request Approval</asp:HyperLink>
                                     <div id="div4" class="noti_bubble"  runat="server" visible="false" style="right: 10px">
                                    <asp:Label ID="GReqApp" runat="server"></asp:Label></div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td id="td_visitor" class="td_d"  runat="server">
                                <div id="noti_Container">
                            <asp:HyperLink ID="HyperLink7" runat="server" style="font-weight: 700"

                                    ToolTip="Visitors" 

                                    NavigateUrl="~/GUI/FmVisitors.aspx" CssClass="lbl">Visitors</asp:HyperLink>
                                     <div id="div_visitor" class="noti_bubble"  runat="server" visible="false" style="right: 10px">
                                    <asp:Label ID="visitor" runat="server"></asp:Label></div>
                                </div>
                                </td>
                        </tr>
                        <tr>
                            <td class="td_Left">
                                 </td>
                        </tr>
                        </table>
                </div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
        </Triggers>
    </asp:UpdatePanel>





here is master page code where i placed web user control

with the Name of Notifications





here is master page code where i placed web user control
with the Name of Notifications

<table class="table1" style="width: 950px">
                        <tr>
                        <td class="td_Left" style="width: 28px" valign="top">
                <div class="div" style="height:auto; width:199px;">
                    <img src="../Images/AC.gif" />
                    <table class="table">
                        style="border: thin groove #a6c8ee; background-color:#f0f0f0; width: 200px;" 
                        frame="box">
                        <tr>
                            <td class="td_d">
                                <asp:Label ID="Label1" runat="server" style="font-weight: 700" 

                                    Text="User Name :  Shah Kamran" CssClass="lbl">
                                
                            </td>
                        </tr>
                        <tr>
                            <td class="td_d">
                                <asp:Label ID="lbl_Email" runat="server" style="font-weight: 700" 

                                    Text="Email: " CssClass="lbl">
                            </td>
                        </tr>
                        <tr>
                            <td class="td_d">
                                <asp:Label ID="lbl_company" runat="server" style="font-weight: 700" 

                                    Text="Company :" CssClass="lbl">
                            </td>
                        </tr>
                        <tr>
                            <td class="td_d">
                                <asp:Label ID="lbl_LoginTime" runat="server" style="font-weight: 700" 

                                    Text="Last Login:" CssClass="lbl">
                            </td>
                        </tr>
                        <tr>
                            <td class="td_d">
                                <asp:Label ID="lbl_CTime" runat="server" style="font-weight: 700" Text="Now : " 

                                    CssClass="lbl">
                                <asp:AnimationExtender ID="lbl_CTime_AnimationExtender" runat="server" 

                                    Enabled="True" TargetControlID="lbl_CTime">
                                
                            </td>
                        </tr>
                        </table>
                        <img src="../Images/NS.png" />
                    <uc3:Notifications ID="Notifications1"  runat="server" />
                </div>
                        </td>
                        <td valign="top">
                         <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                                 
                        </td>
                        </tr>
                        </table>



Note: i am not use Updatepanel in master page


Note: i am not use Updatepanel in master page

推荐答案

A simple answer to your question is No. Because master code becomes part of all those pages which inherit it. So, if you have implemented a timer in your master page, then that timer is going to be part of any other page which is inheriting that master page and thus the timer will also become part of that page. So, better not to include timer your master page until and unless it is really required (keep in mind that that requirement will be kind of MUST for all of inherited pages).
A simple answer to your question is No. Because master code becomes part of all those pages which inherit it. So, if you have implemented a timer in your master page, then that timer is going to be part of any other page which is inheriting that master page and thus the timer will also become part of that page. So, better not to include timer your master page until and unless it is really required (keep in mind that that requirement will be kind of MUST for all of inherited pages).


这篇关于如何停止回发内容页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆