tags:

views:

257

answers:

1

I have the following code:

web.AllowUnsafeUpdates = true; 
SPList list = web.Lists[this.ListName];
SPListItem item = list.Items.Add();
item["linktoAttachment"] = this.SiteAddress +  file.Url;

My question is how can I have friendly link text...

like in a classic hyperlink you have

<a href="technical link">friendly link here</a>

Thanks

+3  A: 

YOur LinkToAttachment field Should of Type Url, then you can use the following:

item["linktoAttachment"] = string.Format("{0},{1}", this.SiteAddress +  file.Url, "friendly link here");

Another option is:

SPListItem newLink = list.Items.Add();
SPFieldUrlValue value = new SPFieldUrlValue();
value.Description = "friendly link here";
value.Url = this.SiteAddress +  file.Url;
newLink["linktoAttachment"] = value;
Colin
thanks, exactly what I was looking for
JL