我有一个页面A,它调用一个控件B,由于某种原因,即使只有一个调用控件B,B也会被执行多次。无论如何我可以暂停代码在第一次执行后被重新执行?也许设置一个bool变量或类似?
谢谢, ç
第A页:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PageA.aspx.cs" Inherits="PageA" %>
<%@ Register Assembly="PlaceHolders" Namespace="PlaceHolders.Sections.B" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<% if (!IsAuthenticated) { %>
<body id="a">
<% } else { %>
<body id="a" class="logged">
<% } %>
<form id="form1" runat="server">
<div class="right">
<div class="container">
<cc1:ControlB ID="CtrlB" runat="server"
CCCToBind="~/ControlB.ascx"/>
</div>
</div>
</form>
</body>
</html>
控制B:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ControlB.ascx.cs" Inherits="Sections.ControlB" %>
<script src="js/jquery.jqzoom.js" type="text/javascript"></script>
<%if (IsHeader)
{ %>
<% }
else
{ %>
<div class="controll">
<div class="control-img">
<div class="toZoom">
<img src=<%# getImage()%> alt="<%= ImgAlt %>" />
</div>
</div>
</div>
<% } %>