CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!
Free 3 Months



Zone: > NEWSGROUP > Asp.Net Forum > microsoft_downloads.css_friendly_control_adapters Tags:
Item Type: NewsGroup Date Entered: 3/31/2008 6:42:52 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 79 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
dlaney
Asp.Net User
CSS Treeview Adapter losing checkbox state3/31/2008 6:42:52 PM

0/0

I am using the css treeview adapter.  It appears that when I do a postback using a checkbox control and set the items programatically, the items do not stay checked.  If I use a button to set the items, it works fine.  If anybody has any idea, please let me know. 

Here is a simple test:

 HTML:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script language='JavaScript' type='text/javascript' src='/scripts/CascadeCheckmarks.js'></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CheckBox ID="chkCheckItem" runat="server" Text="Check last two items" AutoPostBack="true" />
        <br />
        <asp:Button ID="btnCheckItem" runat="server" Text="Check first two items" />
        <asp:TreeView ID="tvListProspect" OnClientClickedCheckbox="CascadeCheckmarks(event)"
            runat="server" CssSelectorClass="SicTreeView" ShowCheckBoxes="All">
        </asp:TreeView>
    </div>
    </form>
</body>
</html>

 

 

vb:

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            LoadList()
        End If
    End Sub
    Private Sub LoadList()
        Dim node As TreeNode
            node = New TreeNode
            node.Value = "0"
            node.Text = "0"
            node.ShowCheckBox = True
            Me.tvListProspect.Nodes.Add(node)

            node = New TreeNode
            node.Value = "1"
            node.Text = "1"
            node.ShowCheckBox = True
            Me.tvListProspect.Nodes.Add(node)

            node = New TreeNode
            node.Value = "2"
            node.Text = "2"
            node.ShowCheckBox = True
            Me.tvListProspect.Nodes.Add(node)

            node = New TreeNode
            node.Value = "3"
            node.Text = "3"
            node.ShowCheckBox = True
            Me.tvListProspect.Nodes.Add(node)

            node = New TreeNode
            node.Value = "4"
            node.Text = "4"
            node.ShowCheckBox = True
            Me.tvListProspect.Nodes.Add(node)

            node = New TreeNode
            node.Value = "5"
            node.Text = "5"
            node.ShowCheckBox = True
            Me.tvListProspect.Nodes.Add(node)
    End Sub


    Protected Sub btnCheckItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCheckItem.Click
            Me.tvListProspect.Nodes(0).Checked = True
            Me.tvListProspect.Nodes(1).Checked = True
    End Sub


    Protected Sub chkCheckItem_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkCheckItem.CheckedChanged
            Me.tvListProspect.Nodes(4).Checked = chkCheckItem.Checked
            Me.tvListProspect.Nodes(5).Checked = chkCheckItem.Checked
    End Sub

dlaney
Asp.Net User
Re: CSS Treeview Adapter losing checkbox state4/1/2008 2:34:18 PM

0/0

After some digging, it appears the problem is in LoadPostData and UpdateCheckmarks.  I believe that LoadPostData wasn't ever implemented right at all. 

Here is what I found out: It appears that UpdateCheckMarks only checks for objects that are in page.request.form, meaning either you checked them on the screen and hit a submit type, or you loaded the tree dynamically on page load and checked some items.  If you were to dynamically check the nodes on a non submit postback, it wouldn't work, which was the original problem.  Once I understood the problem, someone on the team I work with suggested to put the ones I want checked (on a non submit postback) in the context object.  So I created an arraylist, added the items I wanted checked then modified UpdateCheckMarks like so:

Private Sub UpdateCheckmarks(ByVal items As TreeNodeCollection)
            Dim treeView As TreeView = CType(Control, TreeView)
            If ((Not (treeView) Is Nothing) AndAlso (Not (items) Is Nothing)) Then
                For Each item As TreeNode In items
                    If IsCheckbox(treeView, item) Then
                        Dim name As String = (treeView.UniqueID + ("n" _
                                    + (_checkboxIndex.ToString + "CheckBox")))
                        Dim bIsNowChecked As Boolean = (Not (Page.Request.Form(name)) Is Nothing)

                        If bIsNowChecked Then '<- added this, item is not in page.request.form
                            If (item.Checked <> bIsNowChecked) Then
                                item.Checked = bIsNowChecked
                                Extender.RaiseAdaptedEvent("TreeNodeCheckChanged", New TreeNodeEventArgs(item))
                            End If
                        Else
                            If HttpContext.Current.Items.Contains("NewCheckedNodes") Then '<-check to see if context object contains my new arraylist, if it does, process 
                                Dim newCheckedNodes As ArrayList = HttpContext.Current.Items.Item("NewCheckedNodes")

                                If newCheckedNodes.Contains(item) Then
                                    item.Checked = True
                                Else
                                    item.Checked = False
                                End If                                
                            Else
                                item.Checked = False
                            End If
                            
                            item.ImageToolTip = ""
                        End If

                        _checkboxIndex = (_checkboxIndex + 1)
                    End If
                    If HasChildren(item) Then
                        UpdateCheckmarks(item.ChildNodes)
                    End If
                Next
            End If
        End Sub
  
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
CSS Treeview Adapter losing checkbox state - ASP.NET Forums I am using the css treeview adapter. It appears that when I do a postback using a checkbox control and set the items programatically, ...
CSS Treeview Adapter losing checkbox state - ASP.NET Forums CSS Treeview Adapter losing checkbox state. Last post 04-01-2008 10:34 AM by dlaney. 1 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
CodeProject: DataBound TreeView Control. Free source code and ... Jan 6, 2005 ... A way to bind up a simple TreeView control.; Author: Wai Friend; ... I have created the adapters and the dataset similar to your sample code ...
.NET ASP Page 13 - Bytes Site Map RadioButton and CheckBox Controls: Where is the value attribute? .... treeview in master page loses state when new page is selected · Custom Control ...
CodeProject: GridView ObjectDataSource Adapter. Free source code ... Now, it seems a bit absurd to me to lose all the great benefits of encapsulating data .... A CheckBox column that is can be used and bound in a DataGrid ...
TheMSsForum.com >> Asp >> Adding external data into database data ... DataBind() This works fine if only a single row's checkbox has been checked. ..... But on each page load the treeview nodes are collapsed to original state. ...
BusinessRx Reading List : September 2006 - Posts To use the CSS Control Adapter Toolkit, simply follow the below steps using ... use CSS to stylize the control to enable inline checkboxes: ...
Julie Lerman Blog - Tools The TreeView adapter now restores the tree’s expansion state. ...... checking for all kinds of things and including even a checkbox to indicate “overnight”. ...
Recovery Solution™ 6.2 SP2 Reference Guide the As soon as computer goes into idle state check box. After the snapshot starts, ...... If you do, you will effectively lose control over when Recovery ...
The Old .NET Questions Forum Treeview to xml and vice versa Jurgen (1) WYSIWYG HTML editor component? Kris ( 12) ASP.NET Tree Control with Checkboxes Roger (1) ...




Search This Site:










adding columns to the ads table

no dropdownlist for location ?

how to show "what's new" table in default page

how to add another searchtextbox ?

sql db export (dts)

super slow on dual xeon box

how to add a new category

synchronize members table from 2 classified applications

how to improve website rankings using asp.net 2.0?

missing stored procedures

http://onlinetrade.qsh.eu

categories/subcategories

how to host classfields startup on your own server.

content screen blanks out

need help step by step asap

moving photos from db back to upload directory

problems opening the starter kit

getadbyid, add more fileds to adrow

how to change the schema ?

database error

i need help with the classifieds starter kit

customizing postad.aspx by category

how does aspnetdb and classifieddb work together?

deployment from local to remote

ad duration

update fields within database

i need someone with strong knowledge of asp.net and classifieds starter kit to improve my site and implement couples new features

share the code - insideap.com

adding columns to the ads table

topmenurepater in master page

  Privacy | Contact Us
All Times Are GMT