2010-11-02 91 views
0

我有三个选项卡。我想要按需加载,除了第一个标签。如果我点击第二个选项卡,它会加载第二个选项卡。我的问题是如果我加载第二个选项卡,并转到第三个选项卡,当我回到第二个选项卡时,它再次加载。这不应该发生。一旦标签被加载,它不应该再次加载。如何实现这一目标?这里是我的示例代码....根据需要加载Ajax选项卡

<cc1:TabContainer ID="tabEditTskContainer" OnActiveTabChanged="tabEditTskContainer_TabChanged" 
OnClientActiveTabChanged="tabChanged" AutoPostBack="true" runat="server" Height="300px" 
Width="100%" ActiveTabIndex="0"> 
<cc1:TabPanel runat="server" ID="tabEditTskPnl" Enabled="true" HeaderText="Current Balance History" 
    Width="99%"> 
    <HeaderTemplate> 
     Edit Task 
    </HeaderTemplate> 
    <ContentTemplate> 
     <br /> 
    </ContentTemplate> 
</cc1:TabPanel> 
<cc1:TabPanel ID="tabAttach" runat="server" Height="100%" Enabled="true" Width="99%"> 
    <HeaderTemplate> 
     Attachments 
    </HeaderTemplate> 
    <ContentTemplate> 
    </ContentTemplate> 
</cc1:TabPanel> 
<cc1:TabPanel ID="tabAddNotes" Height="100%" runat="server" Enabled="true" Width="99%"> 
    <HeaderTemplate> 
     Notes 
    </HeaderTemplate> 
    <ContentTemplate> 
    </ContentTemplate> 
</cc1:TabPanel> 

<input type="hidden" runat="server" id="hdnTabAttach" /> 
     <input type="hidden" runat="server" id="hdntabAddNotes" /> 


function tabChanged(sender, args) { 
     var tabIndex = sender.get_activeTabIndex(); 
     if (tabIndex == "1") { 
      if (document.getElementById('hdnTabAttach').value == "0") { 
       return true; 
      } 
      else 
       return false; 
     } 
    } 


protected void tabEditTskContainer_TabChanged(object sender, EventArgs e) 
{ 
    try 
    { 
     int intTabIndex = tabEditTskContainer.ActiveTabIndex; 

     if (intTabIndex == 1 && hdnTabAttach.Value != "1") 
     { 
      hdnTabAttach.Value = "1"; 
     } 

     if (intTabIndex == 2) 
     { 

      DBLayer obj = new DBLayer(); 
      SqlCommand cmd = new SqlCommand(); 
      SqlParameter param = new SqlParameter("@fOrderID", SqlDbType.NVarChar, 255); 
      param.Value = Session["selorderID"].ToString(); 
      param.Direction = ParameterDirection.Input; 
      cmd.Parameters.Add(param); 
      param = new SqlParameter("@fncatid", SqlDbType.NVarChar, 25); 
      param.Value = "1"; 
      param.Direction = ParameterDirection.Input; 
      cmd.Parameters.Add(param); 
      DataSet dsGetNotes = obj.ExecuteDatasetSql("[usp_GetNotes]", cmd); 
      Session["GvNotes"] = dsGetNotes; 
      gvNotes.DataSource = dsGetNotes; 
      gvNotes.DataBind(); 

     } 

    } 
    catch (Exception ex) 
    { 

    } 

} 

回答

0

快速方便 - 一个隐藏的表单字段添加到您的aspx页面并添加标签名称,它的价值。然后,在实际加载选项卡之前,请确保该值不包含在隐藏表单字段值中。

我相信这应该可以工作,但问题是您使用的是.Net中内置的ajax内容,我发现这很难解决。通常情况下,客户端,我会做一个全局变量,告诉我什么标签已经加载,只加载一个标签,如果它以前没有做过,否则,我只是显示已经加载的选项卡。

相关问题