Business Cases:
§ Simple Case. (If you want to open SharePoint
dialog and don't care about width, height ...).
§ Complex Case. (To control dialog properties
such as title, width, callback functions ….).
§ Notification. (To notify user about any
information).
§ Loading Wait Screen. (Working on it dialog).
§ Open Modal Dialog in custom action (ECB Menu).
Business Cases Details:
Case One (Simple
Case)
By using
SP.UI.ModalDialog.OpenPopUpPage(url, callback, width, height); javascript function.
url : The URL of the page to be shown in the modal dialog.
callback : function pointer to callback function that runs when the modal dialog is closed.
width : The width of the modal dialog.
height : The height of the modal dialog.
url : The URL of the page to be shown in the modal dialog.
callback : function pointer to callback function that runs when the modal dialog is closed.
width : The width of the modal dialog.
height : The height of the modal dialog.
Demo:
1- Edit page and embed code in it
2- Put this markup in the page source
This method is very simple but it has many
disadvantages:
1- fixed title.
Case One (Complex
Case)
By using Modal
Dialogs.
Modal Dialogs are one of the new features
provided by SharePoint 2010. It's the dialog framework provided by the
JavaScript client object model. Modal Dialogs can fetch data from anywhere and
display it over the page. One good feature about the Modal Dialogs is, there
won't be any navigation to another page, making the user to stay in the context
of the current page. The number of post backs will also be reduced by using
modal dialogs. These dialogs are used in a large scale in many of the
operations, like creating a page, viewing/editing item properties etc.
These dialogs are JavaScript pop up dialogs
with an iFrame in which the data is displayed.
'SP.UI' namespace from the client object
model provides a static class 'SP.UI.ModalDialog' with many methods which are
used for creating dialogs and controlling their behavior.
Demo
1- Create Content Editor
Web Part.
2- Edit source and write
this script
<script
type="text/javascript">
//User
Defined Function to Open Dialog Framework
function
OpenDialog(strPageURL)
{
var dialogOptions =
SP.UI.$create_DialogOptions();
dialogOptions.url = strPageURL;// URL of
the Page
dialogOptions.title = 'Welcome to
SharePoint'
dialogOptions.allowMaximize= true
dialogOptions.width = 750; // Width of the
Dialog
dialogOptions.height = 500; // Height of
the Dialog
dialogOptions.dialogReturnValueCallback =
Function.createDelegate( null, CloseCallback); // Function to capture dialog
closed event
SP.UI.ModalDialog.showModalDialog(dialogOptions); // Open the Dialog
return false;
}
//
Dialog close event capture function
function
CloseCallback(strReturnValue, target)
{
if (strReturnValue === SP.UI.DialogResult.OK)
// Perform action on Ok.
{
alert("User clicked Ok!");
}
if (strReturnValue ===
SP.UI.DialogResult.cancel) // Perform action on Cancel.
{
alert( "User clicked Cancel!");
}
}
</script>
<a
onclick="OpenDialog('http://bing.com');">open dialog</a>
|
Different Properties
There are various properties the showModalDialog()
method accepts through the options object. Below is the list of these
properties
Property Name
|
Type
|
Description
|
allowMaximize
|
boolean (true/false)
|
Determines the visibility of the maximize button (at top right
corner) for the modal dialog
|
Args
|
Object
|
The args property allows us to pass arbitrary properties into
our dialog.
|
autoSize
|
boolean (true/false)
|
|
dialogReturnValueCallback
|
Function
|
This property accepts a callback function which gets executed
when the dialog is closed.
|
Height
|
Numeric
|
The height of the dialog
|
Html
|
HTML Element
|
The HTML to be rendered in the window (when the URL property
is not specified)
|
showClose
|
boolean (true/false)
|
Determines the visibility of the close button (at top right
corner) for the modal dialog
|
showMaximized
|
boolean (true/false)
|
If set to true, the dialog will render maximized, ie., it
fills the available screen space.
|
Title
|
string
|
Title of the modal dialog. When no title is specified, the
title of the document referred to by the Url property is used instead.
|
url
|
string
|
The URL of the page to be shown in the dialog.
|
Width
|
numeric
|
The width of the dialog to be displayed
|
X
|
numeric
|
Specifies the starting position from the left, where the
dialog is to be rendered
|
Y
|
numeric
|
Specifies the starting position from the bottom, where the
dialog is to be rendered
|
Another Demo:
<script
type="text/javascript">
function
ShowWelcomeDialog()
{
var htmlP =
document.createElement('p');
var htmlMsg =
document.createTextNode('Our SharePoint blog');
htmlP.appendChild(htmlMsg);
var options ={
html: htmlP,
title:'Welcome to
SharePoint Developers Hub',
width:400,
height:75,
dialogReturnValueCallback:
ShowStatus
};
SP.UI.ModalDialog.showModalDialog(options);
}
function
ShowStatus(dialogResult, retValue)
{
SP.UI.Notify.addNotification("The
dialog is closed");
}
</script>
<a
title="Open Dialog"
href="javascript:ShowWelcomeDialog();">Open Dialog</a>
|
Case Three (Notification)
Demo
<script>
function Notify()
{
SP.UI.Notify.addNotification("Every
thing is ok.");
}
</script>
<a
href="javascript:Notify();">Notify me</a>
|
Case Four (Loading
Wait Screen)
SP.UI.ModalDialog.showWaitScreenWithNoClose(title,
message, height, width);
Demo
SP.UI.ModalDialog.showWaitScreenWithNoClose(SP.Res.dialogLoading15);
orSP.UI.ModalDialog.showWaitScreenWithNoClose('Loading
Title', 'Loading Message Here...'); |
Case Five (Open Modal Dialog in ECB Menu)
t if you want to open
dialog from ECB menu? Create new custom action in Element.xml file and in UrlAction tag use the
following javascript function.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="{B0B5A0CB-7FBE-4dd6-9B2A-2B1E1321B8F9}"
RegistrationType="List"
RegistrationId="101"
Location="EditControlBlock"
Title="Goto My Blog">
<UrlAction Url="javascript: function
onClose(){ }
var o = {
url: 'http://www.google.com ',
title: 'MyBlog',
allowMaximize: true,
showClose: true,
width: 700,
height: 500,
dialogReturnValueCallback: onClose
};
SP.UI.ModalDialog.showModalDialog(o);"/>
</CustomAction>
</Elements>
|



266 comments
«Oldest ‹Older 201 – 266 of 266 Newer› Newest»I appreciate the depth you went into here. It adds a lot of value to the ongoing conversation about this topic. I am currently exploring the next phase of this trend on my site https://mbwind.com
ReplyBrilliant breakdown. You have highlighted points that many others overlook. I strive to bring this level of detail to the articles on my website as well. It would be an honor to have you visit https://manywaysastrology.com
ReplyThis article serves as a great benchmark for quality content in our niche. I have recently written a piece that functions as a follow up to this topic on my website, would love to know if you agree with my conclusions https://makeukipgreatagain.com
ReplyYour analysis cuts through the noise perfectly. Its refreshing to read content that avoids jargon and goes straight to the point. I apply a similar clear cut philosophy on my website https://marteloderubinero.com . I had love for you to take a look
ReplyThe way you connected these concepts is brilliant. I hadn't considered that angle before. I explore the practical side of these theories on my site, and I invite you to see if it aligns with your views https://mrbones2.co.za
ReplyYou have successfully highlighted the nuances that most people miss. Thank you for this deep dive. I am currently writing about the long term impact of this on my website, and I would value your thoughts https://companionschoice.co.uk
ReplyYou have a knack for foreseeing industry trends. This article is very forward thinking. I am preparing my own audience for these shifts on my website, feel free to visit to see my approach https://cleanerstodaydirect.co.uk
ReplyIncredible article. Your insights are truly eye opening. I would love for you to check out my website at https://hbmodules.co.uk for more content like this.
ReplyThis is one of the best pieces I have read in a long time, brilliant work! Please visit https://uhuruprinters.co.za when you have a moment, i think you will enjoy it.
ReplyAmazing content, thank you for sharing your expertise! Drop by https://forexbrokers-sa.co.za , i have similar topics that might interest you.
ReplySuch a well written and thoughtful article, kudos to you. Feel free to swing by https://midohionews.com for more great reads.
ReplyThis post is pure gold. Your writing is exceptional. Check out https://dialelectrical.co.uk , i believe you will find it valuable.
ReplyLoved every word of this article. You are a talented creator. I would love your feedback on my site at https://isleofmullweavers.co.uk
ReplyWow, this is super helpful. I have been looking for a clear explanation like this. I actually just posted about my experience with this on my website, come check it out https://legitdriverslicense.com
ReplyLove this, your energy really comes through in your writing. I am trying to build a similar vibe on my website, hope you can stop by https://mbscthrive-dcfitness.com
ReplySuch a great read to start my day. Thanks for the inspiration. If you are ever looking for more ideas, my website has a ton of related content https://real-estate-investing-for-beginners.com
ReplyTotally agree with you. Its so important to talk about this. I have dedicated a whole section of my website to this topic if you want to explore more https://shop-nfl.org
ReplySo glad I stumbled upon this post. Keep up the amazing work. I would love for you to visit my site and let me know what you think of my recent updates https://spiedkiks.com
ReplyThis content is really informative and well written. I enjoyed reading it. I also write related articles on my website if you are interested https://schaefer-baustoffe.com
ReplyExcellent post. I learned something new today. If you like this topic, you might enjoy the content on my website too https://gratefulbags.com
ReplyVery insightful article. Thank you for sharing your knowledge. I also write about similar subjects on my website https://noproblemz.com
ReplyThis is a high quality piece of content. Simple, clear, and informative. Feel free to visit my website for related articles https://digipatrika.com
ReplyI really appreciate the depth and clarity of the content provided on this site. https://artisantilenw.org
ReplyThis site consistently delivers content that is both educational and enjoyable to read. https://friendsofhaikustairs.org
ReplyI really enjoy how each article is structured to provide maximum understanding. https://damaulifm.org
ReplyEverything flows logically, follow-up discussion appears on https://isa-corp.com
ReplyEvery article I read here feels thoroughly researched and well-presented. https://nobrazil.com
ReplyThe website offers content that is both practical and intellectually stimulating. https://nobrazil.com
ReplyThe articles are written in a professional yet approachable style that is very inviting. https://bizandroid.org
ReplyI appreciate how the content is organized, making it easy to explore different topics. https://yish.dev
ReplyThe concepts are presented in a relatable way, more examples are on https://whatismagnesiumoil.com
ReplyI love how the articles are structured to deliver maximum understanding and clarity. https://thenewforestcenter.com
ReplyThe writers clearly put a lot of effort into making the content informative and enjoyable. https://m3agecny.com
ReplyReadable and informative at the same time, expanded discussion is on https://wpfpak.org
ReplyThe website consistently delivers content that is educational and well-written. https://leonardowood.com
ReplyI appreciate how the website provides content that is both informative and thought-provoking. https://teplostudio.com
ReplyI am impressed by the effort taken to ensure accuracy and clarity in every post. https://katzen-apotheke.org
ReplyNice pacing that keeps it easy to follow, follow-up details on https://powervoxplus.com
ReplyI find the content very well-researched, making it trustworthy and informative. https://paranoiamachinery.com
ReplyThe website is an excellent example of high-quality, educational content online. https://regenschirme-bedrucken.com
ReplyComfortable to read while learning, more examples are posted on https://palmbeachastro.org
ReplyI appreciate the effort put into ensuring the content is detailed yet understandable. https://hedefweb.com
ReplyThe platform provides information that is useful, practical, and well-explained. https://lieuphaptunhien.com
ReplyReally straightforward explanation, added examples are on https://aleupha.com
ReplySome sections really make sense, continuation is written on https://nhatop1.com
ReplyHelps understand key points quickly, added perspective lives on https://azlhofuf.com
ReplyHelps make sense of complex ideas, further explanation is on https://au-bellybalance.com
ReplyVery understandable approach, follow-up discussion is on https://ketotq.com
ReplyWell done. The structure and explanation are top notch. I share similar content on my website if you had like to explore more https://eastbourneadvisoryservices.co.uk
ReplyExcellent content. I love how detailed and helpful this article is. If you are interested in similar insights, you are welcome to visit my website https://christopher-hastings.com
ReplyAbsolutely brilliant breakdown. You make complex topics feel so easy to understand. Love it! More content like this on my website if you are interested https://blackdogrunsdisney.com
ReplyExcellent explanation and great flow. I truly enjoyed this article. I write about similar topics on my website, feel free to drop by https://amincharkh.com
ReplyThis content is pure gold. Clear, concise, and super valuable. Great job. Feel free to check my site for related deep dives https://naivesl.com
ReplyHands down the most helpful article. I have watched this week. You are incredibly talented. I also collect useful resources here https://networthcoaching.com
ReplyYour passion for this subject really shines through. Fantastic work. If you enjoy this kind of content, my website has more https://biketoledo.net
ReplyExtremely well done. One of the clearest and most professional pieces i have come across. More like this on https://orangechamber.org
ReplyYou have such a gift for teaching. This was genuinely enlightening. I curate similar helpful content here https://infoprona.com
ReplyPhenomenal job. Your attention to detail is impressive. Loved every second of it. Check out my website for more https://seedash.org
ReplyThis is the kind of content the internet needs more of. Excellent work. I also share in depth guides here https://denebstudios.com
ReplySo much value packed into one piece, thank you. You are killing it. More awesome resources on my site https://doithes.com
ReplyMasterfully explained. You really know your stuff. If you liked this, you might enjoy my collection too https://khessels.com
ReplyThis is the kind of content the internet needs more of. Excellent work. I also share in depth guides here https://lshplastic.com
ReplyYou just became my go to source for this topic. Fantastic work. I have more curated content here https://kansascitychiefsprostore.com
ReplyOne of the best pieces i have read in a long time, bravo. Related deep content on my site https://themewpvn.com
ReplyExtremely useful and beautifully made, thank you. Check out my website for more insights https://glocodocument.com
ReplyHelpful without overloading, more content is shared on https://uxdish.com
ReplyPost a Comment