how to display c# object in html? RRS feed

  • Question

  • User-880439067 posted

    Iam working on youtube api v3 to display all the video.

    With the new youtube api v3 I got the data in json form then with Deserialize it is converted to c# object.

    Now my next challenge is to display the data of the C# object in html page.

    VideoTitle video = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<VideoTitle>(fileContents1);


    I have the above line in the code and the video has all the youtube video details. Now I would like to get the  video title which i can access  string videotitle = video.items[1].snippet.resourceId.videoId; but if I try to print this in the html with <% =  videotitle %> it says  The name 'videotitle' does not exist in the current context.


    What is the issue here? Or how will i print video title and url in html? 

    Friday, August 14, 2015 10:58 AM

All replies

  • User-2010311731 posted

    Are you trying to use this on a page with an .htm or .html file extension, or does it have an .aspx extension?  A regular HTML page is not going to work, you need an ASP.Net markup page.


    Friday, August 14, 2015 5:00 PM
  • User-880439067 posted

    Yes, I have all my logic in code behind and trying to display the object in aspx page.

    Title video = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<Title>(fileContents1);

    In video variable i have the details of youtube video. I need to print that in the aspx page. Any idea how do i do? IF i try to put the object variable in <% video.items[0].snippet.title %> it doesn't work. But in code behind i have all the values.

    Monday, August 17, 2015 4:55 AM