TreeView,这东西,正常情况下一般是不用的,不过我们的美工,没弄个树型的样式出来,没折,将就用一下TreeView了
说重点:
环境搭建:一页面,拖一下TreeView控件上去,随便添加几个项。
然后Page_Load事件里输出:
Code
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter write = new HtmlTextWriter(sw);
TreeView1.RenderControl(write);
if (sw != null)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
Response.Write(sw.ToString());
}
public override void VerifyRenderingInServerForm(Control control)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
//不引发"控件必须放在具有 runat=server 的窗体标记内“验证
}
public override bool EnableEventValidation
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
get
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return false;//解决因RenderControl引发的异常
}
}
然后查看页面源文件,发现RenderControl出来的html和自动生成的html是不一样的,主要区别在于折叠的js事件中
关键点来了,为了回调更新TreeView的内容,却发现拿出来的RenderControl的html的代码是有问题的,几经折腾,先绕过了RenderControl,直接抓页面源码,再正则了。这时候,也有一个折腾人的地方,如果请求头没有User-Agent,抓回来的也是和RenderControl输出的一样。
目前是没折的处理方法,抓页面源码再正则进行中。。。。
到于RenderControl为啥输出的和页面直接加载的不一样。。还有待研究。。。知道的说一声
说重点:
环境搭建:一页面,拖一下TreeView控件上去,随便添加几个项。
然后Page_Load事件里输出:
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
关键点来了,为了回调更新TreeView的内容,却发现拿出来的RenderControl的html的代码是有问题的,几经折腾,先绕过了RenderControl,直接抓页面源码,再正则了。这时候,也有一个折腾人的地方,如果请求头没有User-Agent,抓回来的也是和RenderControl输出的一样。
目前是没折的处理方法,抓页面源码再正则进行中。。。。
到于RenderControl为啥输出的和页面直接加载的不一样。。还有待研究。。。知道的说一声