다음을 통해 공유


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

Let's explain how to customize the SharePoint Item From to take parameters from Query String and set them as default values using SharePoint designer. Using this you can open a new Item From by providing parameters as a query string. For example, you can customize one item display form and taking a query String Parameter from that and view **New Item view for another list by providing default values using the Query String. ** 

Steps

Open the SharePoint designer and go to List and Libraries. Open the list that you want.

http://lh3.ggpht.com/_TufE6r6woBg/TOUIO-aKLyI/AAAAAAAAAbw/hqUJGik9Fyk/image_thumb%5B88%5D.png?imgmax=800

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

http://lh5.ggpht.com/_TufE6r6woBg/TOUISjKdcVI/AAAAAAAAAZ8/1Oio-Y3I3oM/image_thumb%5B19%5D.png?imgmax=800 

http://lh4.ggpht.com/_TufE6r6woBg/TOUIXYUF7wI/AAAAAAAAAaE/k6j4_gmblwM/image_thumb%5B18%5D.png?imgmax=800

The created one will come to the list. Click and open the view.

http://lh3.ggpht.com/_TufE6r6woBg/TOUIcg9_GzI/AAAAAAAAAaM/kEx21nZs8ps/image_thumb%5B29%5D.png?imgmax=800

The default New Item Screen will be loaded as follows.

http://lh4.ggpht.com/_TufE6r6woBg/TOUIgOCW02I/AAAAAAAAAaU/rqi0vijjje4/image_thumb%5B37%5D.png?imgmax=800

Delete the default list view and make that empty. You can delete the controls by selecting the area in the design view, If it's fully cleared you can view the following message from the designer.

http://lh4.ggpht.com/_TufE6r6woBg/TOUIhtNsN5I/AAAAAAAAAac/wArR6epa-TI/image_thumb%5B43%5D.png?imgmax=800

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

http://lh5.ggpht.com/_TufE6r6woBg/TOUIkJrf6OI/AAAAAAAAAak/Oh4n3qwBNe8/image_thumb%5B50%5D.png?imgmax=800

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

http://lh3.ggpht.com/_TufE6r6woBg/TOUImKXNsGI/AAAAAAAAAas/xgVBcXOaaKk/image_thumb%5B51%5D.png?imgmax=800

In this example, let's set the comments by using a Query String Parameter. First, change the comments field’s controller to text box.

http://lh6.ggpht.com/_TufE6r6woBg/TOUIo0mx7-I/AAAAAAAAAa0/Vofk9OWnW9c/image_thumb%5B56%5D.png?imgmax=800

Add a Parameter field to get the comments from the Query String.

http://lh5.ggpht.com/_TufE6r6woBg/TOUIsh7B2yI/AAAAAAAAAa8/LfNtS5R0ZTg/image_thumb%5B61%5D.png?imgmax=800

Pass comments using Query String ID: com and store it into the variable param.

 http://lh6.ggpht.com/_TufE6r6woBg/TOUIu5FdIpI/AAAAAAAAAbE/sWqepPXiku4/image_thumb%5B63%5D.png?imgmax=800

Select the comments text box and switch the view to code or split designer mode.

http://lh5.ggpht.com/_TufE6r6woBg/TOUIwweYb_I/AAAAAAAAAbM/DiSIQnmw078/image_thumb%5B68%5D.png?imgmax=800

http://lh6.ggpht.com/_TufE6r6woBg/TOUIygEKFZI/AAAAAAAAAbU/GJu62ciK3oo/image_thumb%5B74%5D.png?imgmax=800

In here go and change the text property to **{$param} **This will set the query string parameter to the text box.

http://lh5.ggpht.com/_TufE6r6woBg/TOUI0beuNvI/AAAAAAAAAbc/ImBynhqxpSs/image_thumb%5B81%5D.png?imgmax=800

You are done.

http://lh5.ggpht.com/_TufE6r6woBg/TOUI2GbTFBI/AAAAAAAAAbk/BQ6vESNk-Pc/image_thumb%5B87%5D.png?imgmax=800