SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Web Part with a grid view and a linkbutton for add item.

I use this code for show modal dialog when linkbutton click .

AddLinkButton.Attributes.Add("onclick",javascript:SP.UI.ModalDialog.ShowModalDialog({url:''});javascript:return false;);

I want refresh the page when modaldialog close.

share|improve this question
up vote 1 down vote accepted

You need to use showModalDialog's dialogReturnValueCallback and in the callback refresh the parent window.

//Using the DialogOptions class.
var options = SP.UI.$create_DialogOptions();

options.title = "My Dialog Title";
options.url = "/_layouts/DialogPage.aspx";
// some other options if needed
options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);

function CloseCallback(result, target) {

You can also define the options using generic object.

share|improve this answer
Thanks a lot :) – ar.gorgin Jan 25 '12 at 7:43
I have tried all of them only Reload(true) works but default message of postback is not acceptable. so still did not found right solution to refresh parent page fully. – user14162 Jan 15 '13 at 21:32

The better way to check return value and use RefreshPage method:

function showDialog(){
    url: urlToOpen,
    title: "title",
    allowMaximize: true,
    showClose: true,
    width: 800,
    height: 600,
    dialogReturnValueCallback: silentCallback
function silentCallback(dialogResult, returnValue) {
    switch (dialogResult) {
        case SP.UI.DialogResult.cancel:

For example, you may not need to do refresh if dialog closed using close button.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.