Tuesday 15 May 2012

Sample Examples of ShowModalDialog

For showing the div:
<script type="text/javascript">
function showDialog() {
var _html = document.createElement('div');
_html.innerHTML = document.getElementById('WfHistory').innerHTML;
var _options = { html: _html , title: "View History",
allowMaximize: false,
showClose: true,
autoSize: true};
SP.UI.ModalDialog.showModalDialog(_options);}
</script>
<asp:LinkButton id="hlViewHistory" runat="server" OnClientClick="showDialog();return false;" Text="Show Full History" />
<div id="WfHistory" style="display:none" >
....
</div>

For showing the aspx page:
<script type="text/javascript">
function showDialog() {
var list = document.getElementById("<%= hdnParamList.ClientID %>").value;
var _options = { title: "View History",
allowMaximize: false,
showClose: true,
autoSize: true,
url: "ViewHistory.aspx?List=" + list };
SP.UI.ModalDialog.showModalDialog(_options);}
</script>
<asp:LinkButton id="lbViewHistory" runat="server" OnClientClick="showDialog();return false;" Text="Show Full History" />script>div id="WfHistory" style="display:none" >

Close Popup inside CodeBehind:
StringBuilder sbScript1 = new StringBuilder();
sbScript1.Append("<script language='javascript'>");
sbScript1.Append("window.frameElement.commitPopup();<");
sbScript1.Append("/script>");
ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "closepopup", sbScript1.ToString(), false);

No comments:

Post a Comment