I am new to Tridion back end coding. I have used the logger for the debug. But I didn't get much information from there. Can anyone please let me know the most common way to debug the code?
I am facing the issue while updating the existing controls which is c# code. The error I am getting is Object reference not set to an instance of an object.
public partial class YoutubeFeedControl : System.Web.UI.UserControl
{
//public string AccountName;
private ILog _logger;
protected string baseUrl = "http://www.youtube.com/feeds/videos.xml?channel_id=UCBtqBoVCQ9JiNqyqYUpuejA";
protected void Page_Load(object sender, EventArgs e)
{
// _logger.DebugFormat("Choose a Country Dropdown: Schema: {0}", baseUrl);
try
{
WebClient c = new WebClient();
c.Encoding = UTF8Encoding.UTF8;
string output = c.DownloadString(baseUrl);
YoutubeRequest request = JsonConvert.DeserializeObject<YoutubeRequest>(output);
Repeater Rpt = base.FindControl("Rpt") as Repeater;
Rpt.DataSource = request.Feed.Videos;
Rpt.DataBind();
}
catch (Exception theException)
{
_logger.DebugFormat("An error occured: {0}\n{1}", theException.Message, theException.StackTrace);
}
}
protected void SetItem(object sender, RepeaterItemEventArgs e)
{
Image image = e.Item.FindControl("Image") as Image;
HyperLink link = e.Item.FindControl("Link") as HyperLink;
Literal date = e.Item.FindControl("Date") as Literal;
Literal views = e.Item.FindControl("Views") as Literal;
Video video = e.Item.DataItem as Video;
image.ImageUrl = video.Thumbnail;
image.AlternateText = video.Title;
link.NavigateUrl = video.Link;
link.Text = video.Title;
date.Text = video.Published.ToString("dd MMM yyyy");
views.Text = video.Views;
}
}