2012-07-12 2 views
0

가 나는 시스템 관리자 탭이 있고 클릭하면 동적 및 데이터베이스 기반이다 아약스 탭 패널을 많이 생성 BEHIND내 상황에서 지연로드를 구현하는 방법은 무엇입니까? ...

<asp:ScriptManager ID="ScriptManager1" runat="server"> 
</asp:ScriptManager> 
<br /> 
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server" Width="100%" ActiveTabIndex="0" 
    CssClass="ajax__tab_header"> 
    <ajaxToolkit:TabPanel ID="TPAdjCal" Width="100%" runat="server"> 
     <HeaderTemplate> 
      <img runat="server" id="imgAdjCalendarleft" visible="false" alt="" src="../images/Tabs/GreenLeftBottom.gif" /><asp:Button 
       ID="imgAdjCalendar" BorderStyle="none" Text="" CssClass="MainTabs" 
       runat="server"></asp:Button><img alt="" src="../images/Tabs/GreenRightBottom.gif" 
        runat="server" id="imgAdjCalendarright" visible="false" /> 
     </HeaderTemplate> 
     <ContentTemplate> 
      <table class="HeaderCaption" id="Table1" cellspacing="0" cellpadding="3" width="100%" 
       border="0" runat="server"> 
       <tr class="PagerRow"> 
        <td> 
         <asp:Label ID="HeaderLabel1" runat="server" Text="Label"></asp:Label> 
         <asp:Label ID="FunctionCode1" runat="server" Text="" Visible="false"></asp:Label> 
        </td> 
        <td> 
        </td> 
        <td> 
        </td> 
       </tr> 
      </table> 
     </ContentTemplate> 
    </ajaxToolkit:TabPanel> 
    <ajaxToolkit:TabPanel ID="TabContainer2" Width="100%" runat="server"> 
     <HeaderTemplate> 
      <img runat="server" id="imgPoliceReportsleft" visible="false" alt="" src="../images/Tabs/GreenLeftBottom.gif" /><asp:Button 
       ID="imgPoliceReports" BorderStyle="none" Text="" CssClass="MainTabs" 
       runat="server"></asp:Button><img alt="" src="../images/Tabs/GreenRightBottom.gif" 
        runat="server" id="imgPoliceReportsright" visible="false" /> 
     </HeaderTemplate> 
     <ContentTemplate> 
      <table class="HeaderCaption" id="Table2" cellspacing="0" cellpadding="3" width="100%" 
       border="0" runat="server"> 
       <tr class="PagerRow"> 
        <td> 
         <asp:Label ID="HeaderLabel2" runat="server" Text="Label"></asp:Label> 
         <asp:Label ID="FunctionCode2" runat="server" Text="" Visible="false"></asp:Label> 
        </td> 
        <td> 
        </td> 
        <td> 
        </td> 
       </tr> 
      </table> 
     </ContentTemplate> 
    </ajaxToolkit:TabPanel> 
</ajaxToolkit:TabContainer> 

CODE : 시스템 관리자 탭 내가 탭을로드하는 loadmanager 메소드를 호출 클릭. . 내가 탭을 sysadmin하는 첫 번째 탭의 데이터를로드하고 모든 탭을 클릭 때 너무 게으른 로딩을 구현하기 위해 노력하고

 protected void LoadManagerTabs(bool runFirstLoad) 
     { 
     if (Session["UserSystemTabs"] == null) 
      { 
    postMessage("You do not have access to any system functions", Constants.ERROR_MSG,false); 
     return; 
    } 

    string[,] functions = Session["UserSystemTabs"] as string[,]; 

    functions.GetLength(0); 
    if (functions.GetLength(0) > 0) 
    { 
     string funccode = functions[0, 0]; 
     if (funccode.Length > 0) 
     { 
      if (isHaveAccess(funccode)) 
      { 
       string pagename = DBUtils.getFuncUrlByCode(funccode); 
       try 
       { 
        eClaim.Controls.Tables.DataTables contr = null; 
        contr = (eClaim.Controls.Tables.DataTables)LoadControl("~/" + pagename + ".ascx"); 
        contr.Key = ""; 
        contr.runPageLoad = runFirstLoad; 

        contr.FuncCode = funccode; 
        TPAdjCal.Controls.Add(contr); 
        TPAdjCal.Visible = true; 
        imgAdjCalendar.Text = functions[0, 1]; 
        HeaderLabel1.Text = functions[0, 1]; 
        FunctionCode1.Text = functions[0, 0]; 
        //imgAdjCalendar.Visible = true; 
       } 
       catch 
       { 
        DataTablesV2 contr = null; 
        contr = (DataTablesV2)LoadControl("~/" + pagename + ".ascx"); 
        contr.Key = ""; 
        //contr.runPageLoad = runFirstLoad; 

        if (ShouldRunPageLoad(funccode) && TabContainer1.ActiveTabIndex.Equals(0)) 
        { 
         contr.runPageLoad = true; 
        } 
        else 
        { 
         contr.runPageLoad = false; 
        } 

        contr.FuncCode = funccode; 
        TPAdjCal.Controls.Add(contr); 
        TPAdjCal.Visible = true; 
        imgAdjCalendar.Text = functions[0, 1]; 
        HeaderLabel1.Text = functions[0, 1]; 
        FunctionCode1.Text = functions[0, 0]; 
        //imgAdjCalendar.Visible = true; 
       } 

       if (TabContainer1.ActiveTabIndex.Equals(0)) 
       { 
        imgAdjCalendar.CssClass = "MainTabsSelected"; 
        imgAdjCalendarleft.Src = "../images/Tabs/LightGreenLeftBottom.gif"; 
        imgAdjCalendarright.Src = "../images/Tabs/LightGreenRightBottom.gif"; 
       } 
       else 
       { 
        imgAdjCalendar.CssClass = "MainTabs"; 
        imgAdjCalendarleft.Src = "../images/Tabs/GreenLeftBottom.gif"; 
        imgAdjCalendarright.Src = "../images/Tabs/GreenRightBottom.gif"; 
       } 
      } 
      else 
      { 
       TPAdjCal.Visible = true; 
       imgAdjCalendar.Visible = false; 
       imgAdjCalendarleft.Visible = false; 
       imgAdjCalendarright.Visible = false; 
      } 
     } 
    } 
    else 
    { 
     TPAdjCal.Visible = true; 
     imgAdjCalendar.Visible = false; 
     imgAdjCalendarleft.Visible = false; 
     imgAdjCalendarright.Visible = false; 
     imgTabScrollright.Visible = false; 
     btnTabScroll.Visible = false; 
     imgTabScrollleft.Visible = false; 
    } 

    if (functions.GetLength(0) > 1) 
    { 
     string funccode = functions[1, 0]; 
     if (funccode.Length > 0) 
     { 
      if (isHaveAccess(funccode)) 
      { 
       string pagename = DBUtils.getFuncUrlByCode(funccode); 
       try 
       { 
        eClaim.Controls.Tables.DataTables contr = null; 
        contr = (eClaim.Controls.Tables.DataTables)LoadControl("~/" + pagename + ".ascx"); 
        contr.Key = ""; 
        contr.runPageLoad = runFirstLoad; 
        contr.FuncCode = funccode; 
        TabContainer2.Controls.Add(contr); 
        TabContainer2.Visible = true; 
        imgPoliceReports.Text = functions[1, 1]; 
        HeaderLabel2.Text = functions[1, 1]; 
        FunctionCode2.Text = functions[1, 0]; 
        //imgPoliceReports.Visible = true; 
       } 
       catch 
       { 
        DataTablesV2 contr = null; 
        contr = (DataTablesV2)LoadControl("~/" + pagename + ".ascx"); 
        contr.Key = ""; 
        contr.runPageLoad = runFirstLoad; 
        contr.FuncCode = funccode; 
        TabContainer2.Controls.Add(contr); 
        TabContainer2.Visible = true; 
        imgPoliceReports.Text = functions[1, 1]; 
        HeaderLabel2.Text = functions[1, 1]; 
        FunctionCode2.Text = functions[1, 0]; 
        //imgPoliceReports.Visible = true; 
       } 

       if (TabContainer1.ActiveTabIndex.Equals(1)) 
       { 
        imgPoliceReports.CssClass = "MainTabsSelected"; 
        imgPoliceReportsleft.Src = "../images/Tabs/LightGreenLeftBottom.gif"; 
        imgPoliceReportsright.Src = "../images/Tabs/LightGreenRightBottom.gif"; 
       } 
       else 
       { 
        imgPoliceReports.CssClass = "MainTabs"; 
        imgPoliceReportsleft.Src = "../images/Tabs/GreenLeftBottom.gif"; 
        imgPoliceReportsright.Src = "../images/Tabs/GreenRightBottom.gif"; 
       } 
      } 
      else 
      { 
       TabContainer2.Visible = true; 
       imgPoliceReports.Visible = false; 
       imgPoliceReportsleft.Visible = false; 
       imgPoliceReportsright.Visible = false; 
      } 
     } 
    } 
    else 
    { 
     TabContainer2.Visible = true; 
     imgPoliceReports.Visible = false; 
     imgPoliceReportsleft.Visible = false; 
     imgPoliceReportsright.Visible = false; 
     imgTabScrollright.Visible = false; 
     btnTabScroll.Visible = false; 
     imgTabScrollleft.Visible = false; 
    } 

아래 샘플. 나는 찾고 있었지만 나는 내 상황에 도움이되는 것을 찾지 못했다. 어떤 도움이 많이 감사 할 것이다.

+0

누군가가 몇 가지 방법을 추출해야한다고 생각합니다. – ChaosPandion

+0

아마도 도움이됩니다. http://stackoverflow.com/q/10931064/284240 –

답변

0

문제는 원하는 것이 webform과 작동하지 않는다. 적어도 이걸 좋아하지 마라. 멀티 뷰 컨트롤을 사용해 볼 수도 있습니다. 또한 동적으로 뷰를 멀티 뷰에 추가 할 수도 있지만, 뷰가 웹 폼에서 제대로 작동하도록 각 요청을 작성해야합니다.

또한 webusercontrols (ascx)에 UI 세부 정보를 캡슐화하고 사용자 정의 컨트롤을 동적으로로드하려고합니다. 이 방법을 사용하면 런타임이 아닌 디자인 타임에 대부분의 레이아웃을 유지할 수 있습니다.

+1

사실이 아닙니다. TabPanels를 쉽게 지연로드 할 수 있습니다. UserControls에 랩핑하고 필요할 때만로드해야합니다 (Tab_Content의 'ActiveTabChanged' 이벤트 핸들러에서 사용자 정의 bindData 메소드를 통해 암시 적으로 page_load가 아닌). 여기 비슷한 질문의 대답은 : http://stackoverflow.com/a/10931323/284240 –

+0

그래서 그것은 가능하지만 직관적이지 않습니다 :) 나는 그 이유만으로도 그것을 피할 수 있습니다. 유지 보수 및 디버깅은 규모의 순서가 더 어려워집니다. –

+0

ASP.NET이 작동하는 방법을 알면 ASP.NET의 다른 어떤 것보다 어렵지 않습니다. –

관련 문제