Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm creating a Custom Field Type. During the creation of the Item the user can insert some link inside of a list. I've overloaded the GetFieldValueAsHtml and GetType to make that work. In my GetFieldValueAsHtml I have this code:

public override string GetFieldValueAsHtml(object value)
{

    string[] indirizzi = base.GetFieldValueAsText(value).Split(';');

    StringBuilder sb = new StringBuilder();
    foreach (string s in indirizzi)
    {
        sb.Append("<a href=\"" + s + "\"> " + s + " </a><br />"); 
    }

    return sb.ToString() + app ;
}

Now I'm interested in improving my element. I'd like to use the link to "Connect" so some SP item wich give me the Name of the file connected by link and the permissions associated. How can I do that?

share|improve this question
    
What's the use of the string app? There is no declaration or values set to it. –  Mike Nov 22 '11 at 15:16
add comment

1 Answer

It sounds like you want to take each of the links that your custom field stores, then connect to SharePoint to find the destination object that the link refers to, and find its name and the permissions associated with it.

If that is the case, I'd have to discourage you from attempting that. The reason is that GetFieldValueAsHtml is called whenever a list item is being rendered inside a list view. If you have a list that contains 30 items, GetFieldValueAsHtml will be called 30 times as the page is being rendered, once for each item in the list.

For this reason, GetFieldValueAsHtml should be fast. 'Connecting to SharePoint' (ie creating and SPSite object) is a relatively expensive operation, and if you are doing this inside GetFieldValueAsHtml, you are likely to seriously degrade the performance of your list.

One exception to this however would be if you were sure that your custom field was not going to be used in list views, but only on the view properties pages. In that case, its probably not as big a deal.

Hope that makes sense.

share|improve this answer
    
Thank you very much.. But i had to solve this problem.. Even if it slows a lot my SP installation =/ I thinks i'll not have list with houndred elements, so it may works fine! If i want to try, how can i do? I'm tryng getting the file with .GetFile(url) but this doesn't consider permissions! –  Ziba Leah Nov 23 '11 at 12:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.