You need to debug the code to see exactly what is in "txtDate_From" and "txtDate_To" as they probably don't have what you expect them to have. If this is browser related then the issue
is with whatever you are doing to populate these textboxes as the server code is browser independent. I guess you are using some javascript or something that isn't working in ie8 as it is in other browsers. Regardless, the actualy issue is highly unlikely
to be the code you have posted.
Use the Developer tool on IE8 (by pressing F12) and see what's happening with the control.
In the code behind, see if you are getting the value back. Check if JavaScript is turned off/on in IE8. Also, check in different conputers - that is on multiple of installations of IE8 just to be sure.
demoninside9
Participant
1184 Points
1698 Posts
very strange: working with mozilla, ie7 and below but not for ie8
Jan 04, 2013 09:19 AM|LINK
hi all the below is my code for some working
try { DateTime Leave_From = DateTime.ParseExact(txtDate_From.Text, "dd/MM/yyyy", null); DateTime Leave_To = DateTime.ParseExact(txtDate_To.Text, "dd/MM/yyyy", null); if (Leave_To < Leave_From) { txtDate_To.Text = ""; WebMsgBox.Show("To date should be greater than From date"); } else { btnSearch.Enabled = true; } } catch (Exception ex) { WebMsgBox.Show("Date is not valid"); }very starnge that this code is working for all browsers like ie7 , mozilla 12.0. but it is not working for ie8 why ?
every time when I put a condition for try catch it shows message "Date is not valid why ?
and if I changed my code's two line like below
AidyF
Star
9204 Points
1570 Posts
Re: very strange: working with mozilla, ie7 and below but not for ie8
Jan 04, 2013 10:23 AM|LINK
You need to debug the code to see exactly what is in "txtDate_From" and "txtDate_To" as they probably don't have what you expect them to have. If this is browser related then the issue is with whatever you are doing to populate these textboxes as the server code is browser independent. I guess you are using some javascript or something that isn't working in ie8 as it is in other browsers. Regardless, the actualy issue is highly unlikely to be the code you have posted.
demoninside9
Participant
1184 Points
1698 Posts
Re: very strange: working with mozilla, ie7 and below but not for ie8
Jan 05, 2013 08:35 AM|LINK
I used calendar extender control with this code as GUI
demoninside9
Participant
1184 Points
1698 Posts
Re: very strange: working with mozilla, ie7 and below but not for ie8
Jan 07, 2013 03:43 AM|LINK
this is my aspx code
<asp:TextBox ID="txtDate_From" runat="server" CssClass="link" Width="180px"></asp:TextBox> <asp:CalendarExtender ID="txtDate_From_CalendarExtender" Format="dd/MM/yyyy" runat="server" Enabled="True" TargetControlID="txtDate_From"> </asp:CalendarExtender> </td> <td style="width: 108px"> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtDate_From" ErrorMessage="Select From Date">*</asp:RequiredFieldValidator> </td> <td style="width: 63px"> </td><td align="left" class="ver11bold">To Date</td> <td align="center" class="ver11bold">:</td><td> <asp:TextBox ID="txtDate_To" runat="server" CssClass="link" AutoPostBack="True" ontextchanged="txtDate_To_TextChanged" Width="180px"></asp:TextBox> <asp:CalendarExtender ID="txtDate_To_CalendarExtender" Format="dd/MM/yyyy" runat="server" Enabled="True" TargetControlID="txtDate_To"> </asp:CalendarExtender> </td> <td> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtDate_To" ErrorMessage="Select To Date">*</asp:RequiredFieldValidator>and this is my code file
protected void txtDate_To_TextChanged(object sender, EventArgs e) { try { DateTime Leave_From = DateTime.ParseExact(txtDate_From.Text, "dd/MM/yyyy", null); DateTime Leave_To = DateTime.ParseExact(txtDate_To.Text, "dd/MM/yyyy", null); if (Leave_To < Leave_From) { txtDate_To.Text = ""; WebMsgBox.Show("To date should be greater than From date"); } else { btnSearch.Enabled = true; } } catch (Exception ex) { WebMsgBox.Show("Date is not valid"); } }please try my code with ie8 and let me know where I am doing wrong
shahed.kazi
All-Star
17953 Points
3635 Posts
Re: very strange: working with mozilla, ie7 and below but not for ie8
Jan 07, 2013 04:17 AM|LINK
Use the Developer tool on IE8 (by pressing F12) and see what's happening with the control.
In the code behind, see if you are getting the value back. Check if JavaScript is turned off/on in IE8. Also, check in different conputers - that is on multiple of installations of IE8 just to be sure.
.NET World |Captcha Control
geniusvishal
Star
14040 Points
2786 Posts
Re: very strange: working with mozilla, ie7 and below but not for ie8
Jan 07, 2013 04:25 AM|LINK
You are Using the Wrong Method over here..
It would be like this:
Refer:
http://msdn.microsoft.com/en-us/library/xhz1w05e.aspx
My Website
www.dotnetvishal.com
demoninside9
Participant
1184 Points
1698 Posts
Re: very strange: working with mozilla, ie7 and below but not for ie8
Jan 07, 2013 04:35 AM|LINK
still same result
but when I run this ; it shows a message box like below
do you want to debug this webpag
geniusvishal
Star
14040 Points
2786 Posts
Re: very strange: working with mozilla, ie7 and below but not for ie8
Jan 07, 2013 04:49 AM|LINK
sys.InvalidoperationException occurs when the method was called but the exception is not caused by invalid arguments..
Debug Your code...
http://msdn.microsoft.com/en-us/library/bb397540%28v=vs.100%29.aspx
My Website
www.dotnetvishal.com
geniusvishal
Star
14040 Points
2786 Posts
Re: very strange: working with mozilla, ie7 and below but not for ie8
Jan 07, 2013 04:50 AM|LINK
Please Go through the links:
http://stackoverflow.com/questions/8266710/javascript-date-parse-difference-in-chrome-and-other-browsers
http://stackoverflow.com/questions/5802461/javascript-which-browsers-support-parsing-of-iso-8601-date-string-with-date-par
http://www.codeproject.com/Articles/14743/Easy-String-to-DateTime-DateTime-to-String-and-For
My Website
www.dotnetvishal.com
demoninside9
Participant
1184 Points
1698 Posts
Re: very strange: working with mozilla, ie7 and below but not for ie8
Jan 07, 2013 04:51 AM|LINK
what I need to change in my code so that It could run also on ie8 as it is perfectly working for ie7, ie6, mozilla, etc.
Thanks