Thursday, June 19, 2008

Couldn’t find ConfigurationManager in System.Configuration?

I am trying to pull an appSettings key from my web.config. In .NET 1.1, we usually use:System.Configuration.ConfigurationSettings.AppSettings["strConnection"].ToString();However, in .NET2.0, using this code will cause the following error:'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'So I just change my code to the following, according to the error above. But the problem is I can’t...

Wednesday, June 18, 2008

Export GridView to PDF

Recently I have been trying to generate some reports to PDF file format from ASP. NET2.0 application. There are a lot of open source PDF libraries out there that you can use to export to PDF such as iTextSharp, Gios PDF .NET Library and PDFSharp. You can go to this link to find out more open source PDF libraries in C#.Later I will show you a working solution on how to export GridView to PDF by using one of the free libraries – iTextSharp.ITextSharp is a port of the iText open source java library written entirely in C# for the...

Monday, June 16, 2008

Error “There was an error opening this document. The file is damaged and could not be repaired”

Few days ago, I was trying to export report in Excel, Word and PDF format.The code that I used works perfect for the Excel and Word file, however, when I tried to do the same on PDF file, I got the following error in Adobe Acrobat Reader version 7 and Internet Explorer 6.0:“There was an error opening this document. The file is damaged and could not be repaired.”I had been searched the solution for hours. I had tried various other things such as Response.BinaryWrite, Response.ClearContent, Response.ClearHeaders, and also some...

Monday, June 9, 2008

Difference between String and string

If you notice in your codes, String, which typed, with an uppercase S is colored in light blue. If it is typed in the lowercase string, it is colored in dark blue. What is the difference between String and string actually?Nothing really, string is a C# language keyword, which is an alias for System.String in .NET framework. So do int = System.Int32, bool = System.Boolean and short = System.Int16. The only subtle difference is that string can be used without a using System; directive, while String needs it, otherwise you will...

Wednesday, June 4, 2008

JavaScript not firing with UpdatePanel

Yesterday when I am dealt with textbox inside an UpdatePanel, I noticed that the JavaScript is not fire when the TextChanged handler is triggered.I had the code lines as below to fire my JavaScript function.string strScript = "javascript:alert('Testing')";ClientScript.RegisterStartupScript(typeof(Page),"clientScript", strScript); After working around with the bug, finally I found the cause. The ClientScript.RegisterStartupScript is just cannot working within an UpdatePanel. To work around the problem there are related static...
 

Get paid for your opinions! Click on the banner above to join Planet Pulse. Its totally free to sign up, and you can earn UNLIMITED. Find out more by visiting PLANET PULSE.
Sign up for PayPal and start accepting credit card payments instantly. http://www.emailcashpro.com
July Code Blog Copyright © 2010 Blogger Template Designed by Bie Blogger Template