Demo live xml rotator does not work for me

5 posts, 0 answers
  1. Felice
    Felice avatar
    198 posts
    Member since:
    Aug 2013

    Posted 03 Mar 2014 Link to this post

    Hi,
    I have copied the code exactly as it is in the demo "live xml" but it is giving me errors on the parsing date. String exception on these methods:


    protected string GetDayOfWeek(string dateTimeString)
              {
                   DateTime result = DateTime.Parse(dateTimeString);
                   string dayOfWeek = Enum.GetName(typeof(DayOfWeek), result.DayOfWeek);
      
                   return dayOfWeek;
              }
      
              protected string GetTimeOnly(string dateValue)
              {
                   return System.DateTime.Parse(dateValue).ToString("hh:mm");
              }
      
              protected string GetDateOnly(string dateValue)
              {
                   return System.DateTime.Parse(dateValue).ToString("ddd, MMM d, yyyy");
              }




    I cannot understand what is wrong. The same code is working in your demo and there are not errors in my code being it the exact copy. I am going mad with this!
    Files are here. I would appreciate your help.

    Thanks a lot.
    Felice
  2. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 06 Mar 2014 Link to this post

    Hi Felice,

    I have isolated the demo in a separate ASPX page, which can be found attached to this post. Please check it and let me know what are the differences in its setup when you compare it to your actual project.

    Since the problem is related to parsing the data from the XML, please clarify if you are using the same data source as the one in the demo. In case it is different, you need to ensure that the information is formatted similarly or change the server-side logic for processing the data.

    Regards,
    Slav
    Telerik

    DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Felice
    Felice avatar
    198 posts
    Member since:
    Aug 2013

    Posted 06 Mar 2014 in reply to Slav Link to this post

    Hi Slav,
    please attached the mentioned demo.
    However, please note that I have copied 100% the demo without any change and I am experiencing the problems described in my original post in which there are also the project files linked.
    Thanks,
    Felice
  5. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 11 Mar 2014 Link to this post

    Hello Felice,

    Please excuse me for missing the example you sent. Nevertheless, when I ran it I did not encounter the problem you described, as you can check in the following screen capture: http://screencast.com/t/tg0NSuKm. Please let me know if there is something specific that needs to be done for the issue to occur.

    What I would suggest is debugging your application in order to determine which is the data source record that causes the exception and what is its format (as the issue stems from the value of dateTimeString according to your description).

    Regards,
    Slav
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  6. Felice
    Felice avatar
    198 posts
    Member since:
    Aug 2013

    Posted 12 Mar 2014 in reply to Slav Link to this post

    Hi Slav,
    I did a couple of changes to your original code to get it working in my context where I am parsing rss from different sources and in some case even mixed rss feeds using yahoo tubes. 
    The problem I was experiencing is related to culture.
    Just for reference to someone else that may experience the same issues, this is what I did:

    In the web.config I added a culture section in system.web:
    <globalization culture="en-US" uiCulture="en-US" />
     
    and the parsing methods have been modified like this:

    protected string GetDayOfWeek(string dateTimeString)
        {  
            DateTime result = DateTime.Parse(dateTimeString, System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat);
            string dayOfWeek = Enum.GetName(typeof(DayOfWeek), result.DayOfWeek);
     
            return dayOfWeek;
        }
     
        protected string GetTimeOnly(string dateValue)
        {
     
            return System.DateTime.Parse(dateValue, System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat).ToString("hh:mm");
        }
     
        protected string GetDateOnly(string dateValue)
        {
     
          string dateOnly=System.DateTime.Parse(dateValue, System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat).ToString("ddd, MMM d, yyyy");
     
            return dateOnly;
        }

     

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017