Adding an ajax tree view control would be very
useful. On the microsoft .NET control the control
postbacks every time you click on a tree node. It
would be alot more slick without these postbacks.
I've posted TreeView control long time ago, let's post once more :) I'm not sure if this control works with current Anthem version as I've branched and modified it a bit (and now I'm on Atlas so couldn't check it)
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASP = System.Web.UI.WebControls;
namespace Library.Web.Ajax.Controls
{
public class TreeView : ASP.TreeView
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
AjaxHttpModule.RegisterControl(this);
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "AjaxTreeViewFunctions", @"
<script language='javascript'>
function SetEventArgument (arg)
{
var form = document.getElementById(Ajax_FormID)
if (form && form.__EVENTARGUMENT) form.__EVENTARGUMENT.value = arg
}
</script>
");
}
Logged In: NO
Another request for a TreeView Control
Thanks
Busta
Logged In: YES
user_id=868615
Originator: NO
I do infact have a treeview that's anthem compatible, for those interested email me at "polterguy _at_ gmail _dot_ com".
Thomas
Logged In: NO
I've posted TreeView control long time ago, let's post once more :) I'm not sure if this control works with current Anthem version as I've branched and modified it a bit (and now I'm on Atlas so couldn't check it)
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASP = System.Web.UI.WebControls;
namespace Library.Web.Ajax.Controls
{
public class TreeView : ASP.TreeView
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
AjaxHttpModule.RegisterControl(this);
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "AjaxTreeViewFunctions", @"
<script language='javascript'>
function SetEventArgument (arg)
{
var form = document.getElementById(Ajax_FormID)
if (form && form.__EVENTARGUMENT) form.__EVENTARGUMENT.value = arg
}
</script>
");
}
protected override void Render(HtmlTextWriter writer)
{
AjaxHttpModule.WriteBeginControlMarker(writer, this);
using (MemoryStream ms = new MemoryStream())
{
StreamWriter sw = new StreamWriter(ms);
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
base.Render(htw);
}
sw.Flush();
ms.Position = 0;
using (StreamReader sr = new StreamReader(ms))
{
writer.Write(ModifyHtml(sr.ReadToEnd()));
}
}
AjaxHttpModule.WriteEndControlMarker(writer, this);
}
string ModifyHtml(string html)
{
StringBuilder sb = new StringBuilder();
int lastPos = 0;
Regex reg = ISS.Library.Utils.RegexUtils.GetRegex(@"href=""javascript:__doPostBack\('(?<id>[^']+)','(?<arg>[^']+).+?onclick=""(?<click>.+?[^""]+)",
System.Text.RegularExpressions.RegexOptions.Compiled | System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline,
true);
foreach (Match m in reg.Matches(html))
{
sb.Append(html.Substring(lastPos, m.Index - lastPos));
sb.AppendFormat("href=\"#\" onclick=\"{0} SetEventArgument('{2}'); Ajax_FireEvent('{1}', function() {{ }}, null, true, true); return false;\"",
m.Groups["click"].Value,
m.Groups["id"].Value,
m.Groups["arg"].Value);
lastPos = m.Index + m.Length + 1;
}
sb.Append(html.Substring(lastPos, html.Length - lastPos));
return sb.ToString();
}
}
}