Copy items to tree nodes.

5 posts, 1 answers
  1. Berkman
    Berkman avatar
    23 posts
    Member since:
    Feb 2013

    Posted 07 Aug 2013 Link to this post

    Hi

    I am using a radlistbox that contains few items populated from DB. The items can be checked and how to copy them to a radtreeview using the server side code. Any samples available?
    Thanks for your replies
    Berk.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Aug 2013 Link to this post

    Hi Berk,

    Please have a look at the following code snippet that I have tried which works fine at my end.

    ASPX:
    <telerik:RadListBox ID="RadListBox1" runat="server" CheckBoxes="true" DataTextField="Text"
        DataValueField="Value" OnLoad="RadListBox1_Load">
    </telerik:RadListBox>
    <telerik:RadTreeView ID="testtree" runat="server">
        <Nodes>
            <telerik:RadTreeNode runat="server" Text="Node 1">
            </telerik:RadTreeNode>
        </Nodes>
    </telerik:RadTreeView>
    <br />
    <telerik:RadButton ID="RadButton1" runat="server" Text="Copy" OnClick="RadButton1_Click">
    </telerik:RadButton>

    C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        foreach (RadListBoxItem item in RadListBox1.CheckedItems)
        {
            RadTreeNode node1 = new RadTreeNode(item.Text, item.Value);
            testtree.Nodes.Add(node1);
        }
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Berkman
    Berkman avatar
    23 posts
    Member since:
    Feb 2013

    Posted 05 Sep 2013 Link to this post

    It worked. Sorry for the late response. Does telerik ajax suite has any controls similar to radpdfviewer in wpf? I am populating pdf file names in a radlistbox which are actually uploaded user files stored inside an upload folder in my project. On clicking each filename i want to open the pdf. This is my requirement.
  5. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Sep 2013 Link to this post

    Hi Berkman,

    The Telerik RadControls for ASP.NET AJAX does not contain any specific controls to view PDF files. One option is you can use the RadWindow to view PDF files. Please have a look at the sample code I tried which works fine at my end. Attach the openPdf javascript method to the OnClientItemDoubleClicked event of the RadListBox.

    ASPX:
    <span class="style1">Double click on file name to view contents</span><br />
    <telerik:RadWindowManager ID="RadWindowManager" runat="server" Width="400px" Height="600px">
    </telerik:RadWindowManager>

    JavaScript:
    <script type="text/javascript">
        function openPdf(sender, args) {
            var filelocation = "UploadedPDFFiles/" + args.get_item().get_text();
            radopen(filelocation, "");
        }
    </script>

    In the above code all the PDF files are stored in a folder called UploadedPDFFiles which is inside the project directory.

    Hope this helps,
    Shinu.
  6. Berkman
    Berkman avatar
    23 posts
    Member since:
    Feb 2013

    Posted 06 Sep 2013 Link to this post

    Excellent solution since users can double click the file name to open it in a window with all options such as print, zoom, download etc. and close it; similar to how we do often. Thanks a lot shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017