Watch this example on YouTube
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JavaScript Check if date is valid.aspx.cs" Inherits="WebTest.JavaScript_Check_if_date_is_valid" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
if (Date.parse("1/1/2000")) {
alert("Valid Date")
}
else {
alert("Invalid Date")
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="ValidateDate();" />
</div>
</form>
</body>
</html>
Friday, 1 July 2016
ASP.NET - IE 10 - Fix Error - csv couldn't be downloaded
Watch this example on youtube:
Replace
StringBuilder sb = new StringBuilder();for (int i = 0; i < 200000; i++)
{
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + Environment.NewLine);
}
string sHeader = "attachement; filename=test.csv";
var exc = HttpContext.Current.Response;
exc.Clear();
exc.ContentType = "application/octet-stream";
exc.ContentEncoding = System.Text.Encoding.Default;
exc.AppendHeader("Content-Disposition", sHeader);
exc.Write(sb.ToString());
exc.Flush();
exc.Clear();
exc.Close();
With
StringBuilder sb = new StringBuilder();for (int i = 0; i < 200000; i++)
{
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + ",");
sb.Append("some data here " + Environment.NewLine);
}
string sHeader = "attachement; filename=test.csv";
var exc = HttpContext.Current;
exc.Response.Clear();
exc.Response.ContentType = "application/octet-stream";
exc.Response.ContentEncoding = System.Text.Encoding.Default;
exc.Response.AppendHeader("Content-Disposition", sHeader);
exc.Response.Write(sb.ToString());
exc.Response.Flush();
exc.Response.End();
exc.ApplicationInstance.CompleteRequest();
Subscribe to:
Posts (Atom)