Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add an URL to a list through SDK 1

Status
Not open for further replies.

theprowler

Programmer
Mar 25, 2005
29
0
0
IT
Hi all,
i've got this little problem:
i've got a "Links" list in which i want to insert a new link but i perform this operation through SDK... I can insert the new item but...

Here's some code:

//updating "Links" list...
//set URL field
this.addedItem["URL"] = this.currentSiteCollection.Url + "/" + this.urlTextBox.Text;

//set Country Name
this.addedItem["Country Name"] = this.titleTextBox.Text; this.addedItem.Update();

As you can see i've created a new item that represents an URL to a new site created.

this is the (ugly) result i get on my page:

"Country Name"
India
----> and on the same row... :)
"URL"

So, this URL is too big, i mean too ugly to see that in a web page..., there's a way to set directly URL description so i can see the description and not the Full URL?

Thanks in advance!

Massimo
 
I've seen somewhere that an URL is made up of 2 strings, web address and description

My question in other words is: How to set an URL description through SDK?

Cheers,

Massimo
 
Well i started a project for u but know i don't have time anymore so here are my results

Code:
if (list.Title == "Links")
{
    Web.AllowUnsafeUpdates = true;
    SPListItem itm = list.Items.Add();
    itm["Title"] = "nieuw";
    itm["URL"] = "[URL unfurl="true"]http://www.test.nl";[/URL]
    itm.Update();					
}

this does add the url but not the name, u prob need to fill in more field a complete list of field names can be found

Also u are not trying to work trough the SDK but trough the object model!!

Greetings!
 
All right, i'm using the object model :) and this is my last message on this topic i promise :)
Don't want to waste your time with those silly questions anymore :)

Your little piece of code stores

" in the URL field but i need to set the description of that path.

SDK says:

"The URL field uniquely consists of two strings separated by a comma and space. One string contains the URL path and the other contains the description used as hyperlinked text".

If you know how to set the "description used as hyperlinked text" i'd be very happy :D

Max
 
I finaly found it!

You fill the URL property by a comma seperated string.

itm["URL"] = "<URL>, <Desciption>";

example:
itm["URL"] = " tekst to show";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top