473,511 Members | 12,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET 2.0 TreeView control postback on checkChanged

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

Sep 13 '06 #1
1 5015
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$ContentPlaceHolde r1$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
Sep 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3929
by: George M. | last post by:
I'm working with the treeview control on an ASP.NET page (written in C#), and I have one built the looks something like: Root |_Category1 |_Site1 |_Report1 |_Report2 |_Site2 |_Report3...
0
464
by: xzzy | last post by:
I am using www.obout.com 's treeview control and their postback dll ( for an aspx web page ). The treeview and no postback works, BUT the postback dll keeps getting removed from the solution. No...
1
693
by: kvicky | last post by:
I am trying to load child nodes to a TreeNode in a TreeView in a ASP.net web application. The Treeview with parent nodes are loaded on a Page_load while doing if( ! ISPostback ) and then in the...
8
12727
by: Matt MacDonald | last post by:
Hi All, I have a form that displays hierarchical categories in a treeview. Ok so far so good. What I was to do is have users be able to select a node in the treeview as part of filling out the...
1
4901
by: doemon | last post by:
Hi, I'm working on a pagination control and I need to dynamically rerender a treeview to display the next set of nodes depending on which page we're on. For example, page 1 will dispaly only...
26
8473
by: JJ | last post by:
Is there any way you can expand a parent node on the treeview control _without a postback_ by clicking on the node text (NOT clicking the expand image URL) ? I want to format the treeview node...
2
5482
by: makennedy | last post by:
Hi Experts, Please help, I am a newbie to ASP.NET 2.0 may be I am doing something wrong or there may be a bug somewhere. Basically I have a TreeView Control which I have created...
2
1158
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm trying to abstract some code from my current code-behind into a user control. There's a CheckChanged event from a radiobuttonlist and i was wondering if i could expose that from the...
2
2903
by: =?Utf-8?B?QW1pciBUb2hpZGk=?= | last post by:
Hi I have a web page that has a TreeView on it. If I DONT'T expand the TreeView nodes, the auto refresh works nicely: my page gets refreshed every minute. As soon as I expand a node on the...
0
7367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.