hi,
I want to deploy Custom Visual Webpart to Office 365 , this custom Visual Webpart was developed for SharePoint 2010 and deployed as Farm Solution before so i want to use this same custom Visual Webpart and deploy it to SharePoint Online. below is the code of the Custom Visual Webpart
using System; using System.ComponentModel; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using System.Text; using System.Web; using System.Globalization; namespace SandBoxSample.SampleWebpart { public partial class SampleWebpartUserControl : UserControl { public partial class InnerPageContent : System.Web.UI.WebControls.WebParts.WebPart { #region Getting the value public InnerPageContent ParentWebPart { get; set; } #endregion protected void Page_Load(object sender, EventArgs e) { try { SPQuery query = new SPQuery(); StringBuilder htmlTag = new StringBuilder(); string imgurl = string.Empty; HttpRequest request = HttpContext.Current.Request; string str = request.ServerVariables["SERVER_PROTOCOL"].Substring(0, request.ServerVariables["SERVER_PROTOCOL"].LastIndexOf('/')) + "://" + request.ServerVariables["SERVER_NAME"]; string pageUrl = this.Page.Request.Url.ToString(); using (SPSite rootSite = new SPSite(pageUrl)) { using (SPWeb web = rootSite.OpenWeb()) { query.Query = "<OrderBy><FieldRef Name=\"Modified\" Ascending=\"False\" /></OrderBy>"; SPList list = web.Lists.TryGetList(ParentWebPart.ListName.ToString()); SPListItemCollection itemColl = list.GetItems(query); idTitle.InnerHtml = "<span class='style1'>" + itemColl[0][displayLanguage + "Title"].ToString() + "</span>"; tdInnerContent.InnerHtml = "<span class='content_text'>" + itemColl[0][displayLanguage + "Content"].ToString() + "</span>"; } } } catch (Exception ex) { // Response.Write(ex.Message); } } } } }
using System; using System.ComponentModel; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; namespace SandBoxSample.SampleWebpart { [ToolboxItemAttribute(false)] public class SampleWebpart : WebPart { // Visual Studio might automatically update this path when you change the Visual Web Part project item. private const string _ascxPath = @"~/_CONTROLTEMPLATES/SandBoxSample/SampleWebpart/SampleWebpartUserControl.ascx"; [WebBrowsable(true)] [WebDisplayName("List Name")] [WebDescription("List Name Detils")] [Personalizable(PersonalizationScope.User)] [Category("List Configuration")] public string ListName { get; set; } protected override void CreateChildControls() { SampleWebpartUserControl control = (SampleWebpartUserControl)Page.LoadControl(_ascxPath); Control control = Page.LoadControl(_ascxPath); Controls.Add(control); } } }
sal