Tuesday, 9 April 2013

SharePoint 2010 – How to open PopUp Dialog in SharePoint Site ?

<script type="text/javascript">

// function OpenWindow(title, url) {// // var options = { url: url, width: 1000, height: 800, title: title };// SP.UI.ModalDialog.showModalDialog(options); // return false;// }
//User Defined Function to Open Dialog Frameworkfunction OpenDialog(strPageURL) {
var dialogOptions = SP.UI.$create_DialogOptions();dialogOptions.url = strPageURL;
// URL of the PagedialogOptions.width = 750; // Width of the DialogdialogOptions.height = 500; // Height of the Dialog// dialogOptions.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback); // Function to capture dialog closed eventSP.UI.ModalDialog.showModalDialog(dialogOptions); // Open the Dialogreturn false;}

// Dialog close event capture functionfunction 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>

//Open at OnClientclick event
<td align="left" colspan="4"><asp:Button ID="btnRemarksHistory" runat="server" Text="Remarks" CssClass="sbtn"OnClientClick="return OpenDialog('/_Layouts/GrowthApp/GrowthRemarks.aspx');" /> <%
--OnClick="btnRemarksHistory_Click"--%></td>

Yaah

//Open at OnClick event
<td align="left" colspan="4">
<asp:Button ID="Button1" runat="server" Text="Remarks" CssClass="sbtn"OnClick="btnRemarksHistory_Click"/>  </td>protected void btnRemarksHistory_Click(object sender, EventArgs e){

string str = SPContext.Current.Site.Url;
btnRemarksHistory.Attributes.Add(
"onclick", "return OpenDialog('/_layouts/GrowthApp/GrowthRemarks.aspx')");
}

No comments:

Post a Comment