Saturday, January 21, 2012

To use one-liner or not to use one-liner?

A recurring problem in many of the projects I'm working on is a link to open a link up in a pop / model window. My first thought was to do as Venkatesh R've described it here http://geekswithblogs.net/venkatx5/archive/2010/11/17/how-to-open-a-page-in-sharepoint-2010-dialog-framework.aspx. By making a new SP.UI. $ create_DialogOptions (); object and call SP.UI.ModalDialog.showModalDialog. Not because it's hard but if you do not need the callback. So it is easier to do as described in the SharePoint Developer Team Blog http://blogs.msdn.com/b/sharepointdev/archive/2011/06/23/how-to-open-a-list-form-in-a-modal-dialog-box.aspx whereas in a one-liner can open link in a model window.
<div id="displayDiv"> <p> Please help us with our survey. Take our poll now! </ P> <input onclick = "javascript: SP.UI.ModalDialog.showModalDialog ({url: '.. / Lists / GBE / NewForm.aspx', title: 'User Survey'}); return false; "id =" btnVote "type =" button "value =" Vote "/> </ div>

Which approach would you choose? Post a comment with your solution.