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 am new to SharePoint and I have created several custom lists. I would like to use visual studio 2010 to create new EDIT/NEW/DISPLAY forms for this list. I can't seem to find anything on the internet explaining how to design these new forms with Visual Studio 2010. I would like for some guidance on how this can be done. I simply want to change the UI of the forms and make it look pretty using JQuery and that is the only purpose I have.

<?xml version="1.0" encoding="utf-8"?>

</Fields>
<Views>
  <View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE">
    <Toolbar Type="Standard" />
    <XslLink Default="TRUE">main.xsl</XslLink>
    <RowLimit Paged="TRUE">30</RowLimit>
    <ViewFields>
      <FieldRef Name="LinkTitleNoMenu"></FieldRef>
    </ViewFields>
    <Query>
      <OrderBy>
        <FieldRef Name="Modified" Ascending="FALSE"></FieldRef>
      </OrderBy>
    </Query>
    <ParameterBindings>
      <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" />
      <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
      <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" />
    </ParameterBindings>
  </View>
  <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
    <Toolbar Type="Standard" />
    <XslLink Default="TRUE">main.xsl</XslLink>
    <RowLimit Paged="TRUE">30</RowLimit>
    <ViewFields>
      <FieldRef Name="Attachments"></FieldRef>
      <FieldRef Name="LinkTitle"></FieldRef>
    </ViewFields>
    <Query>
      <OrderBy>
        <FieldRef Name="ID"></FieldRef>
      </OrderBy>
    </Query>
    <ParameterBindings>
      <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
      <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
    </ParameterBindings>
  </View>
</Views>
<Forms>
  <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
  <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
  <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>

share|improve this question
    
Have you seen sharepoint.stackexchange.com/questions/7417/… ? –  eirikb Sep 26 '12 at 19:00
    
Yeah I actually came across this post several times and I am having a hard time trying to perform the same actions. I simply would like to create new forms for the custom list definition I created In VS2010. Are there any standard documentation explaining the correct "non-hack" way of creating forms. –  Joseph D Surgeon Sep 26 '12 at 19:12
    
To make it real simple. I would like a tutorial that can show me how to create a list definition with all views from within Visual Studio without copying and pasting generated code. I know there is a formal way on how to do custom lists and forms from vs2010 without "hacks" –  Joseph D Surgeon Sep 26 '12 at 19:55

3 Answers 3

up vote 0 down vote accepted

There are Two ways u set your application page as List Default New/Edit/Display Form.

  1. Check This http://ikarstein.wordpress.com/2010/12/29/walkthrough-create-custom-sharepoint-2010-list-form-for-deployment-in-a-visual-studio-2010-project/

  2. also in schema of your custom list definition add this after FieldRefs

     <XmlDocuments>
    <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
      <FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
        <Display>ListForm</Display>
        <Edit>ListForm</Edit>
        <New>ListForm</New>
      </FormTemplates>
    </XmlDocument>
    <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
      <FormUrls xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
        <Edit>HERE IS THE URL OF YOUR CUSTOM PAGE</Edit>            
      </FormUrls>
    </XmlDocument>
     </XmlDocuments>
    
share|improve this answer
    
That was all I needed one more question under the <FormTemplates> node do I specify just the name of the form. and then it uses the FormUrls tag to reference the actual form. Could you post an example of those tabs populated. I really appreciate your help and I will mark your answer as the answer because it answered my question. –  Joseph D Surgeon Sep 27 '12 at 17:13
    
Here is my list schema here I don't see how to implement your code. –  Joseph D Surgeon Sep 27 '12 at 18:29
    
see This screencast.com/t/Tr5shVtu5ZVv –  Vishal_Sharepoint Sep 28 '12 at 5:07
    
Does that go into the Schema file. I see field references under the content type node. But in schema there is a <Fields> and a <ViewFields> node so when I add my content type to the schema should it have field references also. What about the <Forms> tag should this be deleted –  Joseph D Surgeon Sep 28 '12 at 13:03
    
Thank you once again you are really helping me grasp this I am new to sharepoint but not .NEt –  Joseph D Surgeon Sep 28 '12 at 13:04

Below is a beautiful step by step article posted. Kindly go through the same.

(http://ranaictiu-technicalblog.blogspot.in/2011/06/sharepoint-custom-addeditdisplay-form.html)

Thanks, Sandy

share|improve this answer
    
This is great I ended up using Jquery but I will be able to get a lot more functionality this way. Is the SharePoint server Object model available to the aspx page and can you access the controls for each field. –  Joseph D Surgeon Aug 13 '13 at 19:07
    
Yes you can use share point object model to the aspx page.For example if you want to add the items which you have entered in aspx page to a list you can use th ebelow code. –  sandy_9866141457 Aug 14 '13 at 9:57
    
i have posted the code above –  sandy_9866141457 Aug 14 '13 at 13:00
  var list = SPContext.Current.Web.Lists[new Guid(Request.QueryString["list"])];
                var itemId = 0;
                if (string.IsNullOrEmpty(Request.QueryString["id"]) == false)
                {
                    int.TryParse(Request.QueryString["id"], out itemId);
                }
                SPListItem listItem = null;
                if (itemId == 0)
                {
                    listItem = list.AddItem();
                }
                else
                {
                    listItem = list.GetItemById(itemId);
                }
String TaskTitle = Convert.ToString(txtTitle.Text);
            String TaskFrequency = ddlTaskFrequency.SelectedItem.Text;
 listItem["Title"] = TaskTitle;
 listItem["TaskFrequency"] = TaskFrequency;
 listItem.Update();
            Context.Response.Write("<script language='javascript'> window.frameElement.commitPopup();</script>");
            Context.Response.Flush();
            Context.Response.End();

If you are using same aspx page then in edit form you have to load like this.

private void LoadData()
        {
            var list = SPContext.Current.Web.Lists[new Guid(Request.QueryString["list"])];
            var itemId = 0;
            if (string.IsNullOrEmpty(Request.QueryString["id"]) == false)
            {
                int.TryParse(Request.QueryString["id"], out itemId);
            }
            if (itemId != 0)
            {
                var listItem = list.GetItemById(itemId);
                ddlNotificationType.SelectedIndex = ddlNotificationType.Items.IndexOf(ddlNotificationType.Items.FindByText((listItem["NotificationType"] == null) ? string.Empty : listItem["NotificationType"].ToString()));
                txtTitle.Text = (listItem["Title"] == null) ? string.Empty : listItem["Title"].ToString();
                ddlTaskFrequency.SelectedIndex = ddlTaskFrequency.Items.IndexOf(ddlTaskFrequency.Items.FindByText((listItem["TaskFrequency"] == null) ? string.Empty : Convert.ToString(listItem["TaskFrequency"])));
}

and in your aspx page form load call this method

if (!Page.IsPostBack)


LoadData();           {
}
share|improve this answer
    
This so beautifully explained you have just unleashed some new capabilities that I needed so bad. Now I can easily create a master detail form for my list items. I have had a very hard time creating the master/detail type forms. –  Joseph D Surgeon Aug 14 '13 at 13:53

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.