This is a migrated thread and some comments may be shown as answers.

Demo live xml rotator does not work for me

4 Answers 25 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Felice
Top achievements
Rank 1
Felice asked on 03 Mar 2014, 04:20 PM
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

4 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 06 Mar 2014, 11:45 AM
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!

0
Felice
Top achievements
Rank 1
answered on 06 Mar 2014, 01:26 PM
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
0
Slav
Telerik team
answered on 11 Mar 2014, 09:41 AM
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.

0
Felice
Top achievements
Rank 1
answered on 12 Mar 2014, 03:31 PM
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;
    }

 

Tags
Rotator
Asked by
Felice
Top achievements
Rank 1
Answers by
Slav
Telerik team
Felice
Top achievements
Rank 1
Share this question
or