Winsmarts.com

Microsoft MVP

MVP Logo

Awarded the Microsoft MVP Award.

Hosted By

blah!bLaH!BLOG!!

Customize the "NewForm.aspx" page for a SharePoint List

Posted on 5/23/2007 @ 11:00 AM in #Sharepoint | 62 comments | 23138 views

Creating a SharePoint list is hella easy. Point and click - and bingo - you have a form to type in and maintain your data in a structure you specified, and you can then create various views on the data collected.

But what if you wished to customize either the "New" form, or the "Update" form etc?

In this blogpost, I will demonstrate how to customize the New form for the announcements list.

  1. Create an announcements list on your favorite sharepoint site.
  2. Open that site in SharePoint designer.
  3. Go to the announcements list on the left side in the treeview, find the "NewForm.aspx", right click on it, and choose "New from Existing page".
  4. Save that new page at the same level as NewForm.aspx, call it "NewForm2.aspx". (I am only doing this, so if you screw up NewForm2.aspx - you still have NewForm.aspx intact).
  5. Next, find the "PlaceHolderMain" webpartzone. Go ahead and default this WebPartZone to it's default content as shown below -

  6. Next, using a similar smart tag, do "Create Custom Content" for "PlaceHolderMain".
  7. Next, with PlaceHolderMain selected, go to Insert --> SharePoint Controls --> Custom List Form. You will see a dialogbox like this --
  8. You know what to do .. Click OK :).
  9. Great, now you should see SPD reflect the form as follows -
  10. Great, now I'm going to customize this form an WYSIWYG way, and knock off the "Expires". This is real easy frankly, just select the Expires Row, right click, Delete Rows - POOF!
  11. Save the NewForm2.aspx.
  12. Now, right click on the Announcements list in SPD, choose Properties, and go to Supporting Files, click on "Browse" under the "New Item Form", and choose "NewForm2.aspx".
  13. Hit OK.
  14. Go back to the browser, and add a new announcement, you should no longer see the "Expires" field as shown below -

  15. Great, now send me a check for $25 for helping you out. :)

Adios.


On 5/23/2007 3:02:01 PM Rob Garrett said ..
Hmmm, this process looks similar to a customization I constructed when my client wanted to drop off a form field that was autopopulated after a user walloped the OK button. Hell I shoulda blogged about it an earned $25 ;)

On 5/23/2007 3:45:37 PM Sahil Malik said ..
Tell ya what Rob - if someone ever pays me $25, you get to keep $12.50! Fair deal? :)

On 5/24/2007 11:34:52 AM Beatriz said ..
Very very nice the solution! :)

On 5/30/2007 9:16:48 PM Aaron Weiker said ..
Your check is in the mail. :-) I was actually just doing this today; go figure.

On 5/31/2007 6:10:42 AM Sahil Malik said ..
LOL Aaron, heard that before :)

On 6/4/2007 3:13:00 PM Britto said ..
Good tip. I have used this one before. You should point out the fact that the "Attach File" button will not work in the custom form. Try it out and it give you an error mentioning the fact that the form is custom or something like that. If you don't have to used attachments then disable it for the list and the custom form will work great.

On 6/4/2007 3:46:31 PM Sahil Malik said ..
Thanks for the tip Britto. :)

On 6/9/2007 7:26:00 AM Kapil said ..
Hi Sahil,
I saw your video on dnrtv.com, certainly sharepoint is a very good solution. But one question is in my mind, the question is about team site available in sharepoint 2007. when i assign a task to any person. then how he/she can submit report of that task to me, so that i can see all tasks with their related reports. like below. plz help me task1
|
---> Report1
task2
|
---> Report2
Is there any out-of-box capability to do this, if no then how can i accomplish this. plz reply as soon as possible.
yours sincerely
Kapil

On 6/12/2007 9:49:51 AM Schou said ..
Great and how can I do the same but in the opposite way ? I created a column (yes/no checkbox) and now want to include this new checkbox in my new form how do you do that ?

On 6/12/2007 12:01:45 PM Sahil Malik said ..
Schou, The generated default content should already include it. SM

On 7/13/2007 1:52:38 PM Ayub Patel said ..
How would you do in case of two dropdownlist getting data from sharepoint list. Example category and subcategory. On selection of category how do you show only subcategories of selected category in first dropdown.

On 7/17/2007 4:35:41 AM AtFirstSign said ..
i follow on manual, when i set Supporting Files is NewForm2.aspx. it doesn't work. how do i do? pls help.

On 7/17/2007 8:20:12 AM Nithya said ..
Hi, In our project we have cutomized the DispForm.aspx form of some of the custom lists. It works very well in the development server. But when we export the site to another server (like staging server), and invoke a list item in that server, we encounter an Error and the customized page is not rendered.
We found what is causing this problem but we are not able to find a solution to it. The error is caused because the list in the exported site has its own GUID and the customized web part in the DispForm.aspx is still refering to the GUID (which is being used as the list name) that was created in the development server.
We are not able to find a resolution for this issue. Please help if anyone knows.... Thanks in advance.
Nithya.

On 7/24/2007 9:19:39 AM John Lancaster said ..

On 7/27/2007 6:08:17 AM Mala said ..
Hi, Attach file button is not working. When I click on attach file button i get
"Error:This form was customized not working with attachment". Can u send the step for attachment. Thanks in advance.
Mala

On 8/3/2007 7:44:57 PM Mandar said ..
Hi
When I try to insert--> Sharepoint Controls--> Custom List Form(following your example word to word) designer does not do anything. Page stays with empty content. Are there any additional settings that need to be done? I am running WSS 3.0 and trying to customize with Sharepoint Designer 2007.
If I try insert--> Sharepoint Controls--> List Form it works but that is of no use to me since I want to customize the list. Any suggestion would be welcome.

On 8/15/2007 11:00:10 PM Castle said ..
Hello, I'm having a similar issue to the previous entry. Except when I go to Insert > Sharepoint Controls > Custom List Form... the Custom List Form is grayed out. I'm using Sharepoint Designer 2007 on SP2003. Thanks in advance!

On 8/29/2007 11:04:58 AM Pete said ..
That's handy....but....What if.... say you wanted to give the user the option to select one of the field values based on data from another list ? so in this example maybe Title could instead be a dropdown of announcement Types e.g. "News,For Sale,Random Stuff" held in a list. how would I do that ?? My attempts cause SPD to have a freak if you mess around with the default fields. Thanks
Pete

On 9/6/2007 7:51:33 AM Dipti said ..
Hi..
How can I add events to server control button that I have added to a newform.aspx page? Also is it possible to populate a dropdown list from another custom list in this particular form? I need to fire selectedindexchange event for the dropdown list which would populate a list box. The requirement is basically to select a topic and then the respective categories for that topic should be populate in the list box. The user can then selected the categories and add the item. Please let me know if this is achievable. Thanks in advance

On 9/28/2007 12:42:26 AM Abeer said ..
Hi,
Thank you for the steps, all you said works but I then lose the connection between the list and the dispform.aspx page or the NewForm.aspx page! and when I go the properties and try to set them back, it won't save and I ave to recreate the list all over again! any ideas why this is happening?
Thank you,
Abeer

On 10/5/2007 6:44:35 AM Andy said ..
Thank you! Just what I needed! Does anyone know though how I can pre-populate a field with the current users login? I am editing the New Item form for the HelpDesk template and instead we want to have the current users login pre-filled in the Customer people picker field. Thanks!

On 10/29/2007 4:31:50 PM bebina said ..
how do in production environment?

On 10/31/2007 7:26:29 AM Mark H. said ..
Nice thingy! Thanks for you post.
But, have you ever tried it on a calendarlist? It's not working :(
When you try to use it, you get errors. It works on all other types of lists, but no calendar... Can you help me, please? Thanks.

On 11/14/2007 3:38:14 PM Saurabh Aggarwal said ..
There is a drawback of customizing the new item form though. Customizing a newform or edit form for a list causes that form to not "see" changes one makes to the list, in other words if you add new columns to the list, the customized form will not get updated automatically and one needs to make make such changes to the form manually.

On 11/15/2007 7:08:28 AM Gabriel said ..
Hi, Thank you for the post. Does anyone know how to populate a person/group field or any other field getting the value from an URL parameter? Thanks.

On 11/29/2007 11:40:23 PM Andy said ..
Has anyone found a workaround for attaching files? Cause if you chance the form like this attachments stop working... which makes it useless for most of my applications unfortunately :oS
Great article though, just MS throwing rocks on the way!

On 12/3/2007 10:53:17 AM Tim said ..
Am having the same problem as Mandar anyone find a solution yet?

On 12/18/2007 10:37:04 AM farid dehar said ..
hola a todos Escribo en castellano -**** I Write en spanish ***- para resolver el tema de adjuntar ficheros en un formulario personalizado lo he reglado de esta forma 1- tengo una lista con las seguientes columnas :
- Titulo incidencia
- Descripcion incidencia
- Tipo incidencia
- Technic assignado
- Dias de resolución
- Acciones realizadas En el formulario de creacion NewForm.aspx necesito ver solo los campos - Descripcion incidencia
- Tipo incidencia
en el formulario de edicion necesito esditar los campos : - Technic assignado
- Dias de resolución
- Acciones realizadas y visualizar los campos - Titulo incidencia
- Descripcion incidencia
- Tipo incidencia Los campos a ocultar en el NewForm le he puesto con la opcion " OCULTO"
de manera a tener en el formulario NewForm.aspx solo los campos que necesito En el formulario EditForm.aspx he creado un formulario personalizado y he puesto el webpart " ListFormPart " en IsVisible=False <IsVisible>false</Isvisible> y he selecionado el control < WebPartPages:DataFormWebPart con la opcion " IncludeHidden = True " De esta manera en el NewForm.aspx me funciona el " Attach File " y muestro solo los campos que necesito y en el EditForm.aspx muestro todo los campos

On 1/15/2008 8:23:55 AM Tim said ..
Thanks for the help. Your $25 is on its way, I sent a check for $1000 for you to cash keep $25 and send the rest to my poor starving uncle in africa to help him escape.....

On 1/21/2008 11:58:45 AM Ram said ..
hi, i would like to add my custom web part to the list definition and hide the default listview webpart that gets displayed in the DISPFORM.ASPX page. How can i achieve the same using list definitions. Ram

On 1/22/2008 1:19:43 AM Shalini said ..
Hi, Is it possible to add a column where the name of the coumn should be the data entered into its previous column value.
For more clarification.
If suppose i have a column named "Name",so user enters value over there.Now,i would like to know as soon as the users enters the name into the textbox.The textbox value should appear as the next column in the next row.

On 2/21/2008 8:56:18 PM Scott said ..
On step 12 I keep changing it to my new file and hitting OK, but it keeps reverting back to the old file... what am I doing wrong??? Thanks for the step by step.

On 2/22/2008 1:21:25 PM scott said ..
OK.. this is very frustrating because I've retraced my steps 5 times now and this never works. I can customize the form but when I try to reassociate the NewForms2.aspx with the New form option through the Support Files Tab, the changes will not stick. I make the changes, hit apply, test my list and click New gives me a "Invalid Page URL:" error... every time. Please help. By retracing my steps I'm actually deleting the list and starting over from scratch everytime - everytime same result.

On 2/22/2008 2:08:02 PM scott said ..
Finally figured it out... Following these steps results in deleting the ListFormWebPart... Something that I never actually selected and deleted the ListFormWebPart. Seems like you can't help but delete this. So I hid it instead (i.e. didn't follow any of the steps through 6).

On 2/26/2008 11:14:37 AM Kier Simmons said ..
THANK YOU, I've been looking every where for this and I've been getting nothing but overly complex ways to go about it in infopath.

On 2/26/2008 3:01:37 PM carla said ..
Scott, what do you mean you didn't follow any steps through 6? Did you start at step 7?
I am still trying to figure out if there is a way to return the functionality of the attachment after customizing the form? Any help would be greatly appreciated!

On 2/27/2008 11:41:26 AM Jan said ..
Hi, does nobody have the problem attaching files? It´s not working after changing the Form. :-/

On 2/27/2008 3:40:38 PM Kevin Cornwell said ..
See my blog post for more information on this modification. In particular, read the gotchas... http://www.mysharepointblog.com/post/2008/01/Create-a-custom-list-form-for-a-SharePoint-list.aspx

On 3/19/2008 5:35:24 PM Maarten said ..
Is there anyway to change the databinding on the built in listbox -> listbox field control to a custom pre-sorted datasource? I noticed it was doable with dropdown and standalone listboxes but I'd prefer to use the built in control rather than rewriting the wheel.

On 3/26/2008 2:42:45 PM Michael Rose said ..
How do you account for SharePoint not recognizing the new customized form. If you are in designer and right click the list and take a look at supporting forms you will see that once you add a custom list form SharePoint will no longer maintain the url to that new form. I have read in other blogs that this is a bug and Microsoft needs to fix it. I created a new custom form and everytime I click new list item I get no url and my list is busted. I hope Microsoft takes care of this and adds a better dynamic today column.

On 4/2/2008 6:00:00 PM Michael said ..
Has anybody a solution for prepopulating fields in newform.aspx?

On 4/18/2008 6:09:00 AM Johannes said ..
Hi, a lot of you have report that there is no reaction when inserting a "custom list form".
Has any of you already found a solution? The strange thing for me is:
i first made some tests on a custom list which worked fine, but when going to insert this custom list form to my list, it won't do anything.
Whith any other list on the site it works - expect this one. Could it be because of the number of fields? (its a really big list where i need to modify this)
Or is there any way to manually build this form? (without using the "insert" command?) Jo

On 4/29/2008 10:44:12 AM Deena said ..
I also had trouble getting the properties selection for the newform2.aspx to stick. It kept reverting to newform.aspx. So, I renamed the original newform.aspx to newformoriginal.aspx and then I renamed the newform2.aspx to newform.aspx and everything worked fine. I basically still have my backup copy of the original and my new form working. The only thing is that I didn't test attachments and that seems to be an issue so I will try to test that. If anyone has a solution for the attachments, I'd really appreciate hearing about it. Thanks.

On 5/2/2008 9:06:57 AM Yonz said ..
Hi, I had the same issue when changing the "supporting files". Make sure you set the "Content Type Specific Forms" field to "Item" not "Folder". then it works fine.

On 5/15/2008 10:03:35 AM Kandy said ..
Hey ppls... Johannes, I am having the exact same problem (Insert custom list in SharePoint Designer and it does nothing)... I have tried uninstalling and re-installing; using a other pc, nothing thus far worked... The worst part is that it gives absolutely no error information! Please guys, if you solve this - you surely are the MAN! (or WOMAN)! KANDY!

On 5/19/2008 1:42:38 PM Jarrod said ..
Works great, one question now that I can see the drop downs is there any easy way to make them cascade? Parent Child type setup

On 6/7/2008 2:48:14 PM chris said ..
castle asked why the insert custom list form option is grayed out, mine's the same, doesn't seem to matter where i am on the page it is never active, does anyone have an answer for this please.

On 6/24/2008 5:34:19 AM Angel said ..
I have another one...
I make it work with another newform.aspx, but when going by mobile views with "/m" option...I can not see the "New Item" link, in the list...so I can not ceate new items with mobile....with PC views there is no problem.
Any clue what happens with mobile views when creating a customized "newform.aspx" ????

On 6/29/2008 6:50:03 AM Suhaib said ..
hi guys
how to make the OK button add to list without going to allitems.aspx page
coz i dont wont the customer see all data like the administrator please help thanks

On 7/9/2008 10:20:35 AM yzzuF said ..
The only thing i had trouble with was that i was trying to do this with a custom list. If your creating a custom list, when in the "supporting files section.
If you dont change Folder to Item, the changes you made will not stick.

On 7/11/2008 8:26:38 PM Shawn said ..
Chris and Castle...it seems that a step was skipped. You must also select the "PlaceHolderMain(Master)" object, click on it's "right arrow" menu and select "Create Custom Content" to enable, umm, custom content ;)

On 7/14/2008 4:08:23 PM Lisa said ..
Great info....just what I was looking for today! I have several calculated fields in a list and needed to hide two of them from the Display view...lo and behold...no calculated fields display when follow the steps to create custom content.... Can you help pease? :) Thanks!

On 7/21/2008 12:42:49 PM Snehal H.Rana said ..
Hi Suhaib, I am looking for the same solution. I want my "OK" button to be redirected to a different confirmation page. Does anyone has any tip, suggestion or ideas? Thanks
Snehal

On 7/24/2008 3:34:23 PM Micheal G. said ..
Were you clubbed by SP consultants for posting this very useful (To people new to SharePoint) tutorial? Very clean, concise information that worked to the "T" for me. For my purposes I'm not using Attachments so I don't have any feedback on the issues expressed by others. Thanks

On 7/24/2008 4:25:37 PM Sahil Malik said ..
LOL Michael :-)

On 8/4/2008 9:44:10 AM JohnH said ..
Howdy, This worked great for me. However, how do you format these field items now? I don't want the radio buttons under each other - rather side-by-side. Does anyone know where to find information on actual formatting of these formfields? Also, i'm interested if anyone was able to find information about the redirecturl. I want users to enter a new item, have the item submitted and returned back to the new item page. I'll have a separate link for a custom report - not the allitems.aspx. Thanks in advance,
John

On 8/5/2008 1:21:25 AM Adrian said ..
I need to customize the OK button to direct to a confirmation page.

On 8/19/2008 2:47:26 PM Osama Abandeh said ..
I found the solution I found the solution I found the solution!!! You can make kind of workarround to solve this problem: 1- create from existing page
2- go down just below the main web part and insert List Form
3- you can run the form now and see that you have two forms for entering same information
4- delete the second form that you just entered
5- add Custom List form
6- IT WILL WORK AND THIS IS THE SOLVING FOR MICROSOFT BUG :D

On 8/26/2008 8:18:22 AM Poonam said ..
Osama, Can you pls elaborate the steps?

On 8/28/2008 3:36:51 AM Osama Abandeh said ..
Ok Poonam, I will in two or three days, because i'm just buzy now :)

On 9/2/2008 4:10:27 AM Osama Abandeh said ..
Sorry for delay Poonam, the steps are:
1- Right click on NewForm.aspx page and select New From Existing page
2- select the main web part (normally it will be webpartpage:listformwebpart)
3- press right arrow in keyboard and then enter
4- you are in the correct location to add custom component of list
5- Go to Insert->SharePoint Controls->Custom List Form
6- Select the list name and content type and select (edit will be suitable in this case)
7- save the page and test it, it should work fine
8- go page to SPD and delete the first web part
9- you can customize the new form as you wish hope this is clear :)

On 10/2/2008 6:08:11 PM Bill Erickson said ..
I followed the instructions line by line.
the attachment quit working as soon as I deleted the first web part as stated in line 8.
are you able to make a custom form work with attachments??

Please post your comments:


Your feedback will be submitted for moderation, and will appear after it is approved.

Name:  
Email (optional): Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks  
Enter the text you see in the box:
 

Site designed and maintained by Sahil Malik | All Rights Reserved. ©2007 WinSmarts.com.