当前位置:编程学习 > C#/ASP.NET >>

TreeView页面刷新后出现问题




树型支点,第一次打开页面时是正常的,但再刷新后就打不开支点了,就像上图那样,请问怎样解决。


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="menuAction.aspx.cs" Inherits="menuAction" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head runat="server">
    <title>123</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TreeView ID="TreeView1" runat="server" ExpandDepth="0" ImageSet="Arrows">
            <Nodes>
                <asp:TreeNode Text="销售" Value="销售" SelectAction="Expand">
                    <asp:TreeNode Text="现付" Value="现付"></asp:TreeNode>
                    <asp:TreeNode Text="计划" Value="计划"></asp:TreeNode>
                    <asp:TreeNode Text="出货" Value="出货"></asp:TreeNode>
                </asp:TreeNode>
            </Nodes>
            <ParentNodeStyle Font-Bold="False" />
            <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
            <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px"
                VerticalPadding="0px" />
            <NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="5px"
                NodeSpacing="0px" VerticalPadding="0px" />
        </asp:TreeView>
    </form>
</body>
</html>



using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class menuAction : System.Web.UI.Page
{
    OleBaseClass bc = new OleBaseClass();
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Convert.ToString(Session["userid"]) == "")
        {
            Response.Write("<script>parent.location.href='default.aspx';</script>");

        }
        if (!IsPostBack)
        {

        }
    }


}
--------------------编程问答-------------------- 那就在if (!IsPostBack)里写上TreeView1.expand=true;
--------------------编程问答-------------------- TreeView1.ExpandAll();

加上后是全部都打开了,但还是提示脚本出错,
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,