Saturday, April 28, 2012

Creating hyperlink to display New List Form as Popup Dialog

Sharepoint 2010 Popup Dialogue
Someday back while designing a site I was required to have a New Form Link on the Home page and on clicking, it should show the popup Dialog window with the gray background.

Now first thing what came to my mind was to copy the same code from the “Add new Item” Link in List view. I was using IE to see the SharePoint site where I had developer Toolbar or in your case you case if you use Firefox can download firebug or just use view Source. So I Just pressed F12 on the page and the developer toolbar opened through which i coped the code of the link.


 After getting the link, remove the class and id attribute, so finally what I used is the snippet provided below. We can use the same code for any list. We just need to remove the List Id attribute with the correct List Id and the Site Name.

  <a onclick="javascript:NewItem2(event, &quot; http://Sitename /_layouts/listform.aspx?PageType=8&amp;ListId={88D74540-C80B-41BF-B325-EEAED6565385}&amp;RootFolder=&quot;);javascript:return false;" href="/_layouts/listform.aspx?PageType=8&amp;ListId={88D74540-C80B-41BF-B325-EEAED6565385}&amp;RootFolder=" target="_self">
Add New List Item
</a>

So the changes you need to make in the code before use are a)SiteName b)ListId.   In the below screenshot I have used with a content Editor web-part.   

I have added this screenshot showing how I added it to the CEWP and created the link

No comments:

Post a Comment