I'm currently making some customizations to a Document Library in SharePoint 2013, such as a custom filtering webpart. In this Library, I have two fields that originally were (multi)lookup fields containing various labels. The items in these fields are displayed as hyperlinks leading to their respective item.
This have me the idea to, instead, create hyperlinks which automatically filter the Document Library according to the label that was clicked.
My first attempt at this consisted of changing the field type to SPFieldMultiLineText and then generating some hyperlinks that call a C# method, applying the filter.
Examples I found while googling didn't seem to work, though. A lot of people suggest creating LinkButtons, but I think the SPFieldMultiLineText can't handle ASP, only HTML. On the other hand, the Hyperlink column type seems to support only a single item.
I was hoping someone here with more experience in SharePoint might have an idea how I could realize this!
Thanks in advance!
Here's an example of the type of code I've tried
SPFieldMultiLineText richTextField = docItem.Fields.GetField("Personal Labels") as SPFieldMultiLineText; richTextField.AllowHyperlink = true; richTextField.RichTextMode = SPRichTextMode.FullHtml; String richTextFieldAsHTML = richTextField.GetFieldValueAsHtml(docItem["Personal Labels"], docItem); String linkHTML = "<a href='#' runat='server' onclick='MethodToCall()'>" + labelItem.DisplayName + "</a>"; richTextFieldAsHTML += linkHTML; currentDocumentLibrary.ParentWeb.AllowUnsafeUpdates = true; docItem["Personal Labels"] = richTextFieldAsHTML; docItem.Update(); currentDocumentLibrary.ParentWeb.AllowUnsafeUpdates = false;
With the linkHTML string being the most important part. This example only gives a Hyperlink with the desired name, that does nothing when clicked.