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've an application where i show the bunch of lists in a site. I can click add new item right there and i want to redirect the user to the 'add new item URL' for the particular list he has selected. But the URLs are not uniform.

For ex -

For Tasks the add new item URL is http://webapp1/Lists/Tasks/NewForm.aspx. For WorkFlow Tasks it is http://webapp1/WorkFlowTasks/NewForm.aspx

How can i get/built these URLs through code?

share|improve this question
    
Okie i guess it is going to take a long time for me to get an answer here. –  NLV Aug 2 '10 at 6:37
    
Long time, like 2 hours and 9 minutes? –  Ryan Jun 8 '11 at 11:23
    
Sorry for my bad comment. Apologies. –  NLV Jun 8 '11 at 13:36

1 Answer 1

up vote 5 down vote accepted

From MSDN article about SPForm class:

Use the Forms property of the SPList class to return an SPFormCollection object that represents the collection of forms for a list, and use an indexer to return a single form from the collection.

Sample:

SPWeb oWebsite = SPContext.Current.Web;
SPList oList = oWebsite.Lists["Contacts"];
SPFormCollection collForms = oList.Forms;
foreach (SPForm oForm in collForms)
{
    Response.Write(oForm.Url + " :: " + oForm.Type + "<BR>");
}

WorkFlow Tasks is usually system library (for workflow tasks) and you really should not allow people to add tasks in this one.

Use SPList BaseTemplate property to differentiate list types.

share|improve this answer
    
Okie, got it. Thanks for your answer. –  NLV Aug 2 '10 at 10:06
    
How can i substantially differentiate and identify System Libraries from other libraries? –  NLV Aug 2 '10 at 11:16
    
Check BaseTemplate property: msdn.microsoft.com/en-us/library/… –  Toni Frankola Aug 2 '10 at 11:25

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.