开发者

sharepoint 2010 webpart including file code

Can you use "user controls" to include file code in sharepoint 2010 web parts? If not, how do you include a .html file(located in project folder) inside a web开发者_StackOverflow中文版 part .ascx code?

Any help would be appreciated


If you have created a SharePoint project, like cicorias suggested, you can map the CONTROLTEMPLATES (where all UserControls and their referencing files goes to) folder by right-clicking the project -> Add -> SharePoint Mapped Folder -> TEMPLATES/CONTROLTEMPLATES.

Then it should automatically create a folder within, that is named like your SP project and in this folder you put your .html file. In your UserControl you'd reference it like this:

"~/_CONTROLTEMPLATES/SharePointProject/MyFile.html"

When you deploy your solution, the .html will also be deployed, so it's always in the place where it's supposed to be.


Absolutely - see: http://fuchangmiao.blogspot.com/2008/07/use-user-control-in-web-parts.html the same holds true for 2010


If you have Visual Studio 2010, fire up a SharePoint project and add a Visual Web Part - that is just a User control (ascx) that is wrapped in a Web Part wrapper.

Initially, the ascx has a code behind file associated with it; however, you can push all that directly into the ascx file, removing the *.ascx.cs as needed and deploy just the ASCX. Then from there, it just does what plain old ASP.NET does and does the parse on the fly from ascx, to source, then the CSC, JIT process - again, like ASP.NET (since it is ASP.NET) does.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜