This is a migrated thread and some comments may be shown as answers.

Control over Link Text in Hyperlink Manager

1 Answer 66 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Marco asked on 24 Aug 2009, 09:21 AM
I need some help getting the LinkText set;

I'm trying to create a product selector that returns a hyperlink. I've created my own content provider, based on the ProductBrowserContentProvider. It's shows a list of products whom I generate in the ResolveDirectroy function shown in the code below. This works quit nice.
What is returned is a link to my product. It shows the link in the HyperLink Manager window, in both the URL and the LinkText fields.
But I would like to show the productname in the Linktext. 

        public override DirectoryItem ResolveDirectory(string path) 
        { 
            // category 
            DirectoryItem[] directories = GetChildDirectories(path); 
            return new DirectoryItem(GetName(path), EndWithSlash(GetDirectoryPath(path)), path, "", _permissions, GetChildFiles(path), directories); 
        } 
 
        private FileItem[] GetChildFiles(string path) 
        { 
            List<FileItem> products = new List<FileItem>(); 
            long categoryid = GetLastIdFromPath(path); 
            if (categoryid > 0) 
            { 
                ProductFilter filter = new ProductFilter(0); 
                filter.Category = CategoryManager.FindCategory(categoryid); 
                 
                foreach (Product product in ProductManager.FindProducts(filter)) 
                { 
                    string url = "http://${baseurl}/productdetails.aspx?id="
                    url += product.ProductID.ToString(); 
                    url += "&username=${username}&password=${password}"
 
                    // the linktext should be product.TitleActiveLanguage 
                    FileItem product_item = new FileItem(product.GetTitle(Framework.ActiveLanguage, truetruefalsefalse),"", 0, "location", url, product.TitleActiveLanguage, _permissions); 
                    products.Add(product_item); 
                } 
            } 
            return products.ToArray(); 
        }


Is it at all possible to control the link text from something inside a FileItem object?
If not, what do I do to get the linktext to show what I want?

thanks


1 Answer, 1 is accepted

Sort by
0
Lini
Telerik team
answered on 27 Aug 2009, 02:09 PM
Hi Marco,

You can try customizing the DocumentManager.ascx (http://demos.telerik.com/aspnet-ajax/editor/examples/externaldialogspath/defaultcs.aspx) control and writing some custom JavaScript code to populate the link text textbox.

In the DocumentManager.ascx, modify the _setLinkManagerItem() function and in addition to setting the link.href attribute to item.get_url(), set link.innerHTML to the product name - item.get_name().

All the best,
Lini
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Editor
Asked by
Marco
Top achievements
Rank 1
Answers by
Lini
Telerik team
Share this question
or