0
votes

I have been tasked on creating an intranet website for my company. Currently we are using Office 365 SharePoint but my manager wants me to create a custom website which would be built on top of SharePoint. I am looking for ways on how to start. I am using sharepoint designer

What I want to achieve is, if a SharePoint list contains field ID, name, function, I want to retrieve these fields using ASP.net and then display these values in a aspx page in HTML table. The page will be custom built with CSS and jquery which I am not concerned about.

Please just assist me with how to begin. I am good with HTML.

1

1 Answers

0
votes

You could use SharePoint online CSOM sdk to access SharePoint online data.

Sample code:

string login = "[email protected]"; //give your username here  
            string password = "pw"; //give your password  
            var securePassword = new SecureString();
            foreach (char c in password)
            {
                securePassword.AppendChar(c);
            }

            string siteUrl = "https://domain.sharepoint.com/sites/tst";
            using (ClientContext clientContext = new ClientContext(siteUrl))
            {                
                clientContext.Credentials = new SharePointOnlineCredentials(login, securePassword);
                var user = clientContext.Web.EnsureUser(login);
                clientContext.Load(user);
                clientContext.ExecuteQuery();

                var list = clientContext.Web.Lists.GetByTitle("MyDoc3");
                CamlQuery query = new CamlQuery();
                //you could add query condition to query based on other conditions
                query.ViewXml = "<View Scope='RecursiveAll'><Query><Where><And><BeginsWith><FieldRef Name='ContentTypeId'/><Value Type='ContentTypeId'>0x0101</Value></BeginsWith><Eq><FieldRef Name='Author' LookupId='True'/><Value Type='Lookup'>" + user.Id + "</Value></Eq></And></Where></Query></View>";                
                var listItems = list.GetItems(query);
                clientContext.Load(listItems);
                clientContext.ExecuteQuery();

                foreach (var item in listItems)
                {
                    //to do
                }                       
            }