Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / productivity / SharePoint / SharePoint2010

How to Customize the New Item Form to Take Parameters from Query String in SharePoint 2010

4.00/5 (3 votes)
10 May 2011CPOL1 min read 62.1K  
Explains how to customize the New Item form to get parameters from the query string in SharePoint 2010

In this article, I'm going to explain how to customize the SharePoint Item Form to take parameters from a Query String and set them as default values using the SharePoint Designer. Using this technique, you can open a new Item Form by providing parameters as query string. For example, you can customize an item display form and take a query string parameter from that form and view the New Item view for another list by providing the default values using the query string.

Steps

Open the SharePoint Designer and go to Lists and Libraries and open the list you want.

image

Click New and create a New Insert View by providing the name of the view.

image

image

The created view will appear in the list. Click and open the view.

image

The default New Item screen will be loaded as follows:

image

Delete the default list view and make that empty. You can delete the controls by selecting the area in the Design view. If it fully cleared, you will see the following message in the designer.

image

Go to SharePoint Controls and add the Custom List as you want.

image

Select the New Item form and click OK to add the view.

image

In my example, I want to set the comments by using the query string parameter. So I change the Comments field’s controller to a textbox.

image

Then add a parameter field to get the comments form the query string.

image

I'm passing my comments using the query string ID com and it will store it to the variable param.

image

Then select the Comments text box and switch the view to code or split designer mode.

image

image

Go and change the text property to {$param}. This will set the query string parameter to the text box.

image

Now you are done.

image

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)