블로그 제목 그대로,
'Ribbon Menu로 ModalDialog 창 띄워서 부모창에 값 넘기기' 이다.
우선 Ribbon Menu를 만든다.
솔루션 파일에서 우클릭 후에 [Empty Element]를 누른다.
Elements.xml 파일이 생기는데 아래 소스를 참조한다.
<?
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="WON.SharePoint.Ribbon.VideoPlayer" Location="CommandUI.Ribbon" RegistrationType="List" RegistrationId="301"><
CommandUIExtension><
CommandUIDefinitions><
CommandUIDefinition Location="Ribbon.EditingTools.CPInsert.Groups._children"><
Group Id="Ribbon.VideoPlayerGroup" Sequence="80" Title="Video" Template="Ribbon.Templates.Flexible2"><
Controls Id="Ribbon.VideoPlayerGroup.Controls"><
Button Id="Ribbon.VideoPlayerGroup.Button" Command="Ribbon.Command.VideoPlayer" Sequence="15" Image32by32="/_layouts/images/lg_ICWMP.gif" Description="Insert Video from SharePoint Videos" LabelText="Insert Video" TemplateAlias="o1" /></
Controls></
Group></
CommandUIDefinition><
CommandUIDefinition Location="Ribbon.EditingTools.CPInsert.Scaling._children"><
MaxSize Id="CustomEditRibbonActionsOneMaxSize" Sequence="15" GroupId="Ribbon.VideoPlayerGroup" Size="LargeLarge"/></
CommandUIDefinition></
CommandUIDefinitions><
CommandUIHandlers><
CommandUIHandler Command="Ribbon.Command.VideoPlayer" CommandAction="javascript:function addElement(txt) {
var range = RTE.Cursor.get_range();
range.deleteContent();
var selection = range.parentElement();
if (!selection) {
return;
}
var span = selection.ownerDocument.createElement('span');
span.innerText = txt;
range.insertNode(span);
RTE.Cursor.get_range().moveToNode(span);
RTE.Cursor.update();
}
var options = {
url: SP.Utilities.Utility.getLayoutsPageUrl('/solution/video/insertvideoplayer.aspx'),
title: 'Insert Video',
allowMaximize: false,
showClose: false,
width: 480,
height: 120,
dialogReturnValueCallback: Function.createDelegate(null, function (result, returnValue) {
if (result == SP.UI.DialogResult.OK) {
addElement(returnValue);
}
})
};
SP.UI.ModalDialog.showModalDialog(options);
" /></
CommandUIHandlers></
CommandUIExtension></
CustomAction></
Elements>
그 다음, ModalDialog 용 Application Page를 만든다.
<%
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="InsertVideoPlayer.aspx.cs" Inherits="thesource.homeupdate.sea.samsung.com.Layouts.thesource.homeupdate.sea.samsung.com.InsertVideoPlayer" DynamicMasterPageFile="~masterurl/default.master" %>
<
asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server"> <div style="text-align:left">Video Url:
</div> <div style="text-align:right"> <asp:TextBox ID="txtUrl" runat="server" Width="100%"></asp:TextBox><br /><br /> <asp:Button ID="btnAdd" runat="server" Text="Insert" OnClick="btnAdd_Click" /> <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" /> </div> <script type="text/javascript" language="javascript">document.getElementById(
"<%= txtUrl.ClientID %>").focus();document.getElementById(
"<%= txtUrl.ClientID %>").select(); </script></
asp:Content>
using
using
Microsoft.SharePoint;using
Microsoft.SharePoint.WebControls;using
System.Globalization;namespace
thesource.homeupdate.sea.samsung.com.Layouts.thesource.homeupdate.sea.samsung.com{
public partial class InsertVideoPlayer : LayoutsPageBase{
protected void Page_Load(object sender, EventArgs e){
}
protected void btnAdd_Click(object sender, EventArgs e){
string returnValue = txtUrl.Text; if(string.IsNullOrEmpty(returnValue))Page.Response.Write(
"<script type='text/javascript'>window.frameElement.commitPopup('');</script>"); elsePage.Response.Write(
string.Format("<script type='text/javascript'>window.frameElement.commitPopup('<BLOGVIDEO:{0}>');</script>", returnValue));Page.Response.Flush();
Page.Response.End();
}
protected void btnCancel_Click(object sender, EventArgs e){
Page.Response.Write(
"<script type='text/javascript'>window.frameElement.commitPopup('');</script>");Page.Response.Flush();
Page.Response.End();
}
}
}
'SharePoint 2010' 카테고리의 다른 글
Ribbon Menu Hidden (0) | 2016.09.15 |
---|---|
Change IE meta tag from "IE=8" to "IE=9" (0) | 2016.07.12 |
Custom Ribbon Menu (0) | 2016.07.08 |
문서집합(문서관리) 사용방법 (0) | 2013.08.27 |
[선호] 및 [태그 및 메모]를 비활성화는 방법 (0) | 2013.08.13 |