我在我的 on事件上使用Ajax Accordion
了控件,我想设置我在 java 脚本中设置的控件属性。Master Page
Page_Load
SelectedIndex
Accordion
我的问题是每次HiddenField1.Value = " "Page_Load
的值都没有。我没有得到我在 java 脚本中设置的隐藏字段的值,而是得到什么或空字符串。
下面是隐藏字段
<asp:HiddenField ID="HiddenField1" runat="Server" />
注意:(1)我已经HiddenField
完成了我的任务。
(2)我这样做是因为Ajax Accordion在回发后丢失了当前窗格。
<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>
.vb
以下是我在文件中的后端代码
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>