Asp.net Ajax手风琴:回帖后继续打开ajax手风琴平底锅

时间:2012-08-20 05:30:28

标签: asp.net ajax accordion

我在Ajax Accordion Master PagePage_Load使用SelectedIndex控件我希望设置Accordion Page_Load我在java脚本中设置的<asp:HiddenField ID="HiddenField1" runat="Server" /> 属性。

我的问题是每次HiddenField事件中 HiddenField1.Value =“”的值都没有。我没有得到我在java脚本中设置的隐藏字段的值,而不是我得到的东西或空字符串。

以下是隐藏字段

<script type="text/javascript">
        function pageLoad()
         {
            $find('<%= UserAccordion.ClientID %>' + '_AccordionExtender').add_selectedIndexChanged(onAccordionPaneChanged); 
        }

       function onAccordionPaneChanged(sender, eventArgs) 
         { 
           var selPane = sender.get_SelectedIndex();
           document.getElementById('<%=HiddenField1.ClientID%>').value = selPane;
           //alert("SelectedIndex:" + selPane  ); This message fires nicely so i have confirmed that this event work
         }
    </script>

注:(1)我已使用.vb完成任务。 (2)我这样做是因为发回后Ajax Accordion Loses Current Pane

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If HiddenField1.Value = "" Then
        Else

            UserAccordion.SelectedIndex = HiddenField1.Value

        End If
End Sub

以下是<ajax:Accordion ID="UserAccordion" runat="server" SelectedIndex="0" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" FadeTransitions="true" SuppressHeaderPostbacks="true" TransitionDuration="250" FramesPerSecond="40" RequireOpenedPane="false" AutoSize="None" Width="220px" > <Panes > <ajax:AccordionPane ID="AccordionPane1" runat="server" > <Header> <a href="#" class="href">ST-ERP Modules</a></Header> <Content> <asp:Panel ID="UserReg" runat="server"> <asp:TreeView runat="server" ID="treeMainMenu" DataSourceID="SiteMapDataSource1" NodeIndent="10" Width="150px" OnTreeNodeDataBound="treeMainMenu_TreeNodeDataBound"> <ParentNodeStyle Font-Bold="False"></ParentNodeStyle> <HoverNodeStyle ForeColor="#447BD4" Font-Underline="True"></HoverNodeStyle> <SelectedNodeStyle HorizontalPadding="0px" ForeColor="#DD5555" VerticalPadding="0px" Font-Bold="True" Font-Underline="True"></SelectedNodeStyle> <NodeStyle NodeSpacing="0px" HorizontalPadding="0px" ForeColor="#447BD4" VerticalPadding="0px" Font-Size="8pt" Font-Names="Verdana"></NodeStyle> </asp:TreeView> </asp:Panel> </Content> </ajax:AccordionPane> <ajax:AccordionPane ID="AccordionPane2" runat="server"> <Header> <a href="#" class="href">User Detail</a></Header> <Content> <asp:Panel ID="Panel1" runat="server"> <asp:TreeView runat="server" ID="TreeView1" DataSourceID="SiteMapDataSource2" NodeIndent="10" Width="150px"> <ParentNodeStyle Font-Bold="False"></ParentNodeStyle> <HoverNodeStyle ForeColor="white" Font-Underline="True"></HoverNodeStyle> <SelectedNodeStyle HorizontalPadding="0px" ForeColor="#DD5555" VerticalPadding="0px" Font-Bold="True" Font-Underline="True"></SelectedNodeStyle> <NodeStyle NodeSpacing="0px" HorizontalPadding="0px" ForeColor="White" VerticalPadding="0px" Font-Size="8pt" Font-Names="Verdana"></NodeStyle> </asp:TreeView> </asp:Panel> </Content> </ajax:AccordionPane> <ajax:AccordionPane ID="AccordionPane3" runat="server"> <Header> <a href="#" class="href">Job Details</a> </Header> <Content> <asp:Panel ID="Panel2" runat="server"> ddddddddddddd</asp:Panel> </Content> </ajax:AccordionPane> </Panes> </ajax:Accordion> 文件

中的后端代码
{{1}}

修改 手风琴控制代码。

{{1}}

3 个答案:

答案 0 :(得分:1)

尝试在树视图的TreeNodeDataBound事件处理程序中清除Node的NavigateUrl属性:

protected void treView_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
{
    e.Node.NavigateUrl = null;
}

答案 1 :(得分:0)

我已经解决了这个问题,请看我在这篇文章中的回答 Ajax Accordion Loses Current Pane

如果链接断开,则在下方:

我通过使用Query String链接来解决这个问题,如下所示

url="~/Opportunity/Indent.aspx?index=1" // replace 1 with your desired index

并在页面加载事件中编写类似这样的内容

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 

        Dim selectedindex As String = Request.QueryString("index")
        UserAccordion.SelectedIndex = selectedindex



    End Sub

答案 2 :(得分:0)

我使用会话变量工作(即Accordion.SelectedIndex = Session(&#34; AccordionIndex&#34;)但是QueryString的工作方式也一样(除非你想从URL中删除索引,然后会话状态会更好地工作)