Newbie question - how to load local data into the Win8 Metro style grid application template RRS feed

  • Question

  • I am new to development in general so I appreciate the help.  I am trying to build a grid application using the template provided in VS and simply adding my own content instead of the placeholder content.  In the data/data.js file, there is a variable for item content which contains some HTML:


    itemContent = "<p>Curabitur class aliquam vestibulum nam curae...</p>";

    The HTML content I want to use in the item details pages contains multiple paragraphs, so it is very cumbersome to cut and paste that directly into data.js file, as is shown in the template.  Also, VS only allows one line for all that HTML content so its really a pain to edit because I have to horizontally scroll for a very long time.

    I want to extract out the HTML content into a separate file within my project and then call it from the itemContent variable.  How do I do that?  Should I use a text or XML file instead? 

    Any help much appreciated. 

    Wednesday, February 22, 2012 1:51 PM

All replies

  • Robby,

    There are many ways to accomplish this.  You could use readtext and writetext: http://social.msdn.microsoft.com/Forums/en-US/winappswithhtml5/thread/d3865033-8da6-427f-895a-67abe983762a


    Jeff Sanders (MSFT)

    Wednesday, February 22, 2012 2:14 PM
  • Thanks for your prompt response but I am not sure how to apply it.  I am a designer trying to see if I can build a Win8 app so please assume very basic HTML and JS knowledge only on my part.

    So to make it work, do I

    Set up a JSON file that contains my content?

    Where in the .js do I put the readtext and writetext in relation to the itemContent variable?

    Is there a step-by-step tutorial or sample I can download.  Nothing fancy...I want the most basic loading local, static data into the variable.

    Wednesday, February 22, 2012 2:29 PM
  • this is the way to put an image into a variable:

    var image = "images/myImage.jpg";

    This returns the image

    Now, I want to do the same thing with a a text file

    var content = "files/content.txt";

    This returns the the path to the file not the information in the file.

    How do I get the information in the content.txt into the content variable?

    Saturday, November 3, 2012 9:25 PM