commenturl.NavigateUrl = "javascript:ShowPage('" + SPContext.Current.Web.Url + "/SitePages/Sample.aspx?ID=" + id + "')"; ;
private string GetScript()
{
string script = string.Concat("<script type='text/javascript'>",
"ExecuteOrDelayUntilScriptLoaded(ShowPage, 'sp.js');",
"function ShowPage(URL) ",
" {var options = SP.UI.$create_DialogOptions();",
"options.url=URL;",
"options.title='Delegate';",
"options.autoSize = true;",
"options.showClose=true;",
"options.allowMaximize=false;",
"options.dialogReturnValueCallback= Function.createDelegate(null,DialogCallBack);",
"SP.UI.ModalDialog.showModalDialog(options);}",
"function DialogCallBack(dialogResult, returnValue) ",
"{ if (dialogResult== SP.UI.DialogResult.cancel){",
"var notifyId = SP.UI.Notify.addNotification('Message cancelled', false);",
"window.location.href='/SitePages/Home.aspx';",
"SP.UI.ModalDialog.close(dialogResult); }",
"if (dialogResult== SP.UI.DialogResult.OK)",
"{ window.location.href='/SitePages/Home.aspx';",
"SP.UI.ModalDialog.close(dialogResult); ",
"}};</script>");
return script;
}
Call this script in Page Load:
ScriptManager.RegisterStartupScript(this.Page, GetType(), "popup", GetScript(), false);
private string GetScript()
{
string script = string.Concat("<script type='text/javascript'>",
"ExecuteOrDelayUntilScriptLoaded(ShowPage, 'sp.js');",
"function ShowPage(URL) ",
" {var options = SP.UI.$create_DialogOptions();",
"options.url=URL;",
"options.title='Delegate';",
"options.autoSize = true;",
"options.showClose=true;",
"options.allowMaximize=false;",
"options.dialogReturnValueCallback= Function.createDelegate(null,DialogCallBack);",
"SP.UI.ModalDialog.showModalDialog(options);}",
"function DialogCallBack(dialogResult, returnValue) ",
"{ if (dialogResult== SP.UI.DialogResult.cancel){",
"var notifyId = SP.UI.Notify.addNotification('Message cancelled', false);",
"window.location.href='/SitePages/Home.aspx';",
"SP.UI.ModalDialog.close(dialogResult); }",
"if (dialogResult== SP.UI.DialogResult.OK)",
"{ window.location.href='/SitePages/Home.aspx';",
"SP.UI.ModalDialog.close(dialogResult); ",
"}};</script>");
return script;
}
Call this script in Page Load:
ScriptManager.RegisterStartupScript(this.Page, GetType(), "popup", GetScript(), false);
No comments:
Post a Comment