i fixed it myself.
1. made my own class that derives from the TreeView control.
2. implemented a override for Render method that adds a javascript
eventhandler to the checkboxes
3. added a dummy control whose postback call is called by the
checkboxes from my treeview
-------- code for overridden render method: --------
protected override void Render(HtmlTextWriter writer)
{
StringBuilder builder = new StringBuilder();
using(StringWriter stringWriter = new StringWriter(builder))
{
HtmlTextWriter tempWriter = new HtmlTextWriter(stringWriter);
base.Render(tempWriter);
}
string find = "<input type=\"checkbox\" ";
string replace = "<input type=\"checkbox\"
onClick=\"ReloadTreeView();\" ";
writer.Write(builder.ToString().Replace(find, replace));
}
------------ code for javascript function ---------
function ReloadTreeView(){
document.getElementById('ctl00_ContentPlaceHolder1_checkDoPostBack').checked
= true;
setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$checkDoPostBack\',\'\')',
0);
}
japi wrote:
> Hi all,
>
> I have a TreeView control in my ASP.NET 2.0 Web application with
> checkboxes enabled.
>
> I would like to generate a postback when a user ticks or unticks a
> checkbox. As far as i know, this is not possible out of the box.
>
> Does anyone have a solution/workaround/hack for this?
>
> Cheers,
> Japi