Expression > 論壇首頁 > Expression Blend + SketchFlow > Save data in http session object
發問發問
 

已答覆Save data in http session object

  • 2009年11月5日 下午 07:05ddaoliver 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Hello,

       I need my Expression blend application to store a few piece of data in a browser cookie.  I am currently using VS 2008 and I thought I could use the session object to store the data so it would persist after the application is closed.

       The session object is defined in the library System.web.dll.  Unfortunately, when I try to reference this library I get an error stating that the library can not be added as it was not built against Silverlight runtime.

       Can an expression blend app save data into a session object? 

    Thanks in advanced for your help,
    Didier

解答

  • 2009年11月10日 下午 11:07ddaoliver 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆
    For anyone interested it turns out Silverlight uses a costruct called isolated storage.  Below is some sample code that shows you how to store variables into this storage:

    // Create an instance of IsolatedStorageSettings.

     

    private IsolatedStorageSettings userSettings = IsolatedStorageSettings.ApplicationSettings;

    //***************************************************************************************

     

    // Fetch the value of the saved searches from the isolated storage
    //***************************************************************************************
    foreach (KeyValuePair<string,object> k in userSettings) {
    // Add a SavedQuery object to the Search object
    SavedQueries savedquery = new SavedQueries();
    savedquery.name = k.Key;
    savedquery.fql = (
    string)k.Value;
    search.savedqueries.Add(savedquery);
    }

    // Add a SavedQuery object to the Search object
    SavedQueries savedquery = new SavedQueries();
    savedquery.name = savequerynametextbox.Text;
    savedquery.fql = search.espfql;
    search.savedqueries.Add(savedquery);
    // Add a key and its value.
    userSettings.Add(savedquery.name, savedquery.fql);

    • 已標示為解答ddaoliver 2009年11月10日 下午 11:07
    •  

所有回覆

  • 2009年11月10日 下午 11:07ddaoliver 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆
    For anyone interested it turns out Silverlight uses a costruct called isolated storage.  Below is some sample code that shows you how to store variables into this storage:

    // Create an instance of IsolatedStorageSettings.

     

    private IsolatedStorageSettings userSettings = IsolatedStorageSettings.ApplicationSettings;

    //***************************************************************************************

     

    // Fetch the value of the saved searches from the isolated storage
    //***************************************************************************************
    foreach (KeyValuePair<string,object> k in userSettings) {
    // Add a SavedQuery object to the Search object
    SavedQueries savedquery = new SavedQueries();
    savedquery.name = k.Key;
    savedquery.fql = (
    string)k.Value;
    search.savedqueries.Add(savedquery);
    }

    // Add a SavedQuery object to the Search object
    SavedQueries savedquery = new SavedQueries();
    savedquery.name = savequerynametextbox.Text;
    savedquery.fql = search.espfql;
    search.savedqueries.Add(savedquery);
    // Add a key and its value.
    userSettings.Add(savedquery.name, savedquery.fql);

    • 已標示為解答ddaoliver 2009年11月10日 下午 11:07
    •