locked
SPWeb.Proberties From SilverLight? RRS feed

  • Question

  • I can not access the SPWeb from Serverlight becouse I want to check for some variables saved there ?

     

    Also I want to create a Timer .., there is no Timer control in silverLight.

     

     


    thank u for help
    Thursday, January 19, 2012 2:57 AM

Answers

  • I've just tested the following code from a Console Application...and that works    

     

        //putting value with Server Object Model
                using (SPSite site = new SPSite("http://intranet.contoso.com"))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllProperties["test"] = "TestValue";
                            web.Update();
                    }
                }
                //retrieving value with the client object Model
                using (ClientContext context = new ClientContext("http://intranet.contoso.com"))
                {
                    Web web = context.Web;
                    context.Load(web);
                    context.Load(web.AllProperties);
                    context.ExecuteQuery();
                    Console.WriteLine (web.AllProperties["test"].ToString());
                }


    Serge Luca; SharePoint MVP ; blog: http://sergeluca.wordpress.com/ Devoteam Belgium. http://twitter.com/sergeluca
    • Proposed as answer by Ahmed Naji Monday, January 23, 2012 5:51 AM
    • Marked as answer by Wayne Fan Thursday, January 26, 2012 9:15 AM
    Sunday, January 22, 2012 12:51 PM

All replies

  • I found the property bag sorry ..,

    I just want the Timer now .


    thank u for help
    Thursday, January 19, 2012 3:07 AM
  • I use this line for proprety bag

    SPWeb.Propertyes but it return null always.

     

     lblCount.Content = Microsoft.SharePoint.Client.ClientContext.Current.Web.AllProperties["MyKyeName"].ToString()
    


    thank u for help
    Thursday, January 19, 2012 3:46 AM
  • I got stuck ,

    Please help me ,

    I got maney errors which i dont know all of them :

    like : I cant call the UI from back end.

    and : I can't go cross threads ...,

     

    I Just want to get the SPWeb.Properties ... which I think it have to be with an easier way !!

     


    thank u for help
    Sunday, January 22, 2012 6:56 AM
  • I've just tested the following code from a Console Application...and that works    

     

        //putting value with Server Object Model
                using (SPSite site = new SPSite("http://intranet.contoso.com"))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllProperties["test"] = "TestValue";
                            web.Update();
                    }
                }
                //retrieving value with the client object Model
                using (ClientContext context = new ClientContext("http://intranet.contoso.com"))
                {
                    Web web = context.Web;
                    context.Load(web);
                    context.Load(web.AllProperties);
                    context.ExecuteQuery();
                    Console.WriteLine (web.AllProperties["test"].ToString());
                }


    Serge Luca; SharePoint MVP ; blog: http://sergeluca.wordpress.com/ Devoteam Belgium. http://twitter.com/sergeluca
    • Proposed as answer by Ahmed Naji Monday, January 23, 2012 5:51 AM
    • Marked as answer by Wayne Fan Thursday, January 26, 2012 9:15 AM
    Sunday, January 22, 2012 12:51 PM
  • Thank you all , Yes it solved My problem :)

     


    thank u for help
    Monday, January 30, 2012 7:04 AM