사용자 지정 리본을 만드는 동안 elements.xml을 편집하는 더 좋은 방법이 있습니까?

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/85725

문제

이 기사 참고 자료.Per GeneraCodicicetagcode 파일의 내 코드는 다음과 같습니다.

<CommandUIHandler
    Command="NewRibbonButtonCommand" 
    CommandAction="javascript: MULTIPLE
                               LINES
                               OF
                               JAVASCRIPT
                               CODE">
.

Elements.xml와 같은 기본 JavaScript 객체에 적어도 IntelliSense가있는 것과 같은 CommandAction 속성에서 JavaScript 코드를 편집하는 더 좋은 방법이 있습니다.지금 현재 저는 꽤 기본적인 XML 편집기를 사용하고 있습니다.소스 코드 편집기 및 HTML 편집기와 같은 다른 편집자는 도움이되지 않습니다.document를 편집 할 때 도구 상자가 비어 있고 Elements.xml에 대해 모든 태그를 사용할 수 있는지 알 수 없습니다.

Visual Studio 2012를 사용하고 있습니다.

도움이 되었습니까?

해결책

Yeah, it is pretty common problem. No matter how you try to edit your code it will be difficult to read, debug, manage, and update, when it is written inside elements.xml.

I know that question is about the editor itself, but sometimes it is much better to write your JavaScript code in another .js file, and use only reference in CommandAction. You can load your script in several ways from custom action xml:

  1. Write another custom action with ScriptLink location. Pros - easy to use, cons - it will be loaded on everypage inside your custom action scope (site, web, etc.). Show me how it is done.
  2. Use Script On Demand (SOD) technique to load your script dynamically from inside CommandAction script. SOD can give you magic, because it can load your script only when ribbon tab is opened and this way you can gain performance. Show me SOD 'bible'

Why this way is better. When you have your JavaScript code not in elements.xml but in external files and you need to update your code inside JavaScript it is much easier. You will not need to update your custom actions, you just only need to upgrade your JavaScript files, no matter there they are, in Style Library or in _layouts folder. Debugging of separate JavaScript file is also easier, that inline code.

다른 팁

While we are working with Sharepoint xml files like Feature.xml, Elements.xml or ONET.xml files we wont get any intellisense by default.

But for any developer it is hard to remember all these information. So, here is the easiest way to get the intellisense

  1. Open your xml file in Visual studio.
  2. Go to properties pane of the xml file and click on schema and browse for the file
  3. locate file named "wss.xsd" from C:/Program Files/Common Files/Microsoft Shared/web server extensions/12/TEMPLATE/XML/wss.xsd (12 for MOSS, 14 for SP 2010 and 15 for SP2013)

Note : this file will have all the xml defined functions which is easily recognized by the visual studio.

enter image description here

Then you will get the intellisense for the SharePoint solution..

Credit :- http://kancharla-sharepoint.blogspot.com/2012/03/how-to-get-intellisece-for-featurexml.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top