protected void DownloadFile(string Path, string FileName)
{
try
{
string strURL = Path;
WebClient req = new WebClient();
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer = true;
response.AddHeader("Content-Disposition", "attachment;filename="+FileName);
byte[] data = req.DownloadData(Server.MapPath(strURL));
response.BinaryWrite(data);
response.End();
}
catch (Exception ex)
{
}
}

Programming is fun and interesting. As you all know, sometime we programmers stucks in the middle way of coding without getting a solution. Blogs like this will help us to find a path to solve our problems. The contents of this blog are the solutions that I found by myself and from other sources. Sharing such solutions is also interesting. Thank you!
Sunday, May 24, 2015
Asp.net C# code for download file
Friday, May 15, 2015
Check all Check boxes in a check box list ASP.NET + Jquery
Design
<asp:CheckBox ID="checkAllImport" runat="server" AutoPostBack="false" Text="Select All" />
<asp:CheckBoxList ID="chkOptions" runat="server" RepeatColumns="5" RepeatDirection="Horizontal"></asp:CheckBoxList>
Script
<script type="text/javascript">
$(document).ready(function() {
$("#<%=checkAllImport.ClientID %>").change(function() {
$("input[id *='chkOptions']").prop("checked", this.checked);
})
});
</script>
Wednesday, April 22, 2015
Sorting rows in a data table C#
Create a new DataTable from a DataView that you create from your original DataTable.
Apply whatever sorts and/or filters you want on the DataView and then create a new DataTable from the DataView using the DataView.ToTable method
Apply whatever sorts and/or filters you want on the DataView and then create a new DataTable from the DataView using the DataView.ToTable method
DataView dv = ft.DefaultView;
dv.Sort = "occr desc";
DataTable sortedDT = dv.ToTable();
Monday, April 20, 2015
How to stop IIS asking authentication for default website on localhost
IIS uses Integrated Authentication and by default IE has the ability
to use your windows user account...but don't worry, so does Firefox but
you'll have to make a quick configuration change.
1) Open up Firefox and type in about:config as the url
2) In the Filter Type in ntlm
3) Double click "network.automatic-ntlm-auth.trusted-uris" and type in localhost and hit enter
1) Open up Firefox and type in about:config as the url
2) In the Filter Type in ntlm
3) Double click "network.automatic-ntlm-auth.trusted-uris" and type in localhost and hit enter
Subscribe to:
Posts (Atom)