Thursday, 12 July 2012

Sharepoint designer 2010 , Create Custom List Forms With Asp.net Controls and Fields Validation


As SharePoint designer is no code solution for SharePoint, you can see there are list of all asp.net controls available in SharePoint designer,
I am looking to create new item Form using Custom asp.net controls
Step 1: Create List Named as “Contacts” (You can Use any Name) with following columns.
Title Single line of text
Address Multiple lines of text
E-Mail Single line of text
Step 2: Open SharePoint Site in SharePoint Designer
            Navigate to List and libraries; Select the List named as contacts.
            Select the List settings for Ribbon and then select List Form or you will find same option at
Right              
side in second group/panel Click New. And Give some appropriate name to page.
You can see below screen shot as well to follow the Steps
               
               
Step 3 : Edit page in advance mode

Now Delete the Email Address Field from Form ->

Now go to insert and select Asp.net Controls and Select Text Box Control.


Note its Id will be display and control is selected; now associate this control with SharePoint List Column.

After that Add asp.net regular Expression validation Control to validate the Email Address field.
Follow the same steps as Insert -> Asp.net -> Regular Expression Control.
Open its Properties Window or you can edit its properties in Source View. Properties to be set such as Control to Validate, Error Message, Set Focus, Regular expression etc. like I have select its email Address  Validation you can write you own by selecting Custom Option,
“{} “ these braces did not work in SharePoint , so you cannot use them in regular expression.

Now save it and Open it in browser.
Type invalid email address it will Show error message