Customizing NewForm.aspx RRS feed

  • Question

  • I want to customize NewForm.aspx associated with a list. It has two dropdowns, one is "Authors" and another is "Books"

    I want on selection of Author, his books should be loaded in "Books" dropdown list.. and by default first Author and his books should be selected.

    Please suggest what would be the best approach to do this. ?


    Saturday, April 23, 2011 7:48 AM


All replies

  • Hi Zia,

    You should not do this action by default features of sharepoint designers.

    create web part with Sharepoint programming (object model or web service).

    1- in this web part add 2 drop down list (asp.net controls) , in Authors drop down list bind "distinct Author from list", when select items from authors drop down, bind data (post back or ajax) to Books drop down list. (for query from sharepoint list use CAML query).


    Saturday, April 23, 2011 10:30 AM
  • Hey Zia,

    Check out SPServices which is a jQuery library that wraps SharePoint's Web Services as well as a couple of other utility methods to help with exactly what you are trying to do.

    Specifically look at the "SPCascadeDropdowns" method:


    There are lots of examples and the documentation on the site is great. You'll basically just drop a CEWP on the page and a few lines of jQuery and it will set up the drop down relationship you need. 

    • Marked as answer by Zia Shaikh Thursday, April 28, 2011 11:18 AM
    Saturday, April 23, 2011 1:59 PM
  • Hi,


    According to your description, in my limited experience, I suggest that you should use DropDownList to be bound to a particular Column of a SharePoint List. The following code could be help you:

    if (!Page.IsPostBack)


                using (SPSite site = new ("http://yoursharepointsite"))


                    using (SPWeb web = site.OpenWeb())


                        SPList list = web.Lists["NameOfYourList"];

                        dropSite.DataSource = list.Items;

                        dropSite.DataValueField = "Title"; // List field holding value - first column is called Title anyway!

                        dropSite.DataTextField = "Title"; // List field holding name to be displayed on page





    In addition, I have found a blog, please refer to:



    Best Regards
    David Hu


    Tuesday, April 26, 2011 1:30 AM
  • Hi Zia, You can customize OOTB list forms with InfoPath, and add data source with filer on the Drop Down Filed. Although there is an example of exactly what you want to apply inside "SharePoint 2010 in Action - section 7.2 Customizing Out-Of-The-Box forms with InfoPath, Page # 162" Regards
    Tuesday, April 26, 2011 8:10 AM
  • Try using this from Codeplex

    Also refer to the following link for step by step implementation

    Tuesday, April 26, 2011 9:01 AM
  • Thanks to all. But so many ways to do this..


    BUT which one would be the best approach ? Eg: if I create a web-part that's time consuming. same as if i use info-path is there any disadvantage of using info-path ?

    Can the infopath form be embedded into sharepoint page so that no one would know this was created with infopath ?
    Tuesday, April 26, 2011 11:00 AM

    Hi, Take a look at this article and you will find the answers to your questions about InfoPath :)






    Tuesday, April 26, 2011 11:34 AM
  • If all you are trying to achieve is a cascading drop down effect there is no need to create a custom web part  or infopath form. 


    All you have to do is:


    1) download jQuery library http://docs.jquery.com/Downloading_jQuery

    2) download SPServices: http://spservices.codeplex.com/

    3) Add a content editor web part to your newForm.aspx page (to get newform in edit mode do: (http://siteurl/Lists/ListName/NewForm.aspx?ToolPaneView=2)

    4) Add a script to the CEWP that references the libraries from #1 and #2 and executes SPServies Cascade Drop Down built in method: http://spservices.codeplex.com/wikipage?title=$().SPServices.SPCascadeDropdowns&referringTitle=Documentation


    That's it.. your done... go spend your time on other issues. 

    • Marked as answer by Zia Shaikh Thursday, April 28, 2011 11:19 AM
    Tuesday, April 26, 2011 1:48 PM
  • Thanks Mark Rackley.

    Would you please tell me at what location should I place spservices and jquery files. I mean physically at what location so that i can reference them from within my page. ?


    Wednesday, April 27, 2011 8:34 AM
  • Hi, I often create a new folder in Style library, like /Style librarty/Scripts/ where I store scripts that can be reused. Read more about this at http://spservices.codeplex.com/documentation
    Blog: chrisstahl.wordpress.com Twitter: @Cstahl
    Wednesday, April 27, 2011 9:32 AM
  • I have done using JQuery

    try this link


    Destin -MCPD: SharePoint Developer 2010, MCTS:SharePoint 2007 Application Development
    • Marked as answer by Zia Shaikh Thursday, April 28, 2011 11:18 AM
    Wednesday, April 27, 2011 10:54 AM
  • Hi Zia.... I would also recommend a central script repository as Christian suggested, either using a sub folder in the Style Library or creating a new document library called "Scripts".



    Wednesday, April 27, 2011 11:28 AM
  • Thanks to all. It solved my problem. Special thanks to Destin for sharing code on his blog, and to everyone who helped me guided me step by step in this thread.

    Best Regards

    Thursday, April 28, 2011 8:38 AM