adsense

Friday, August 31, 2012

asp.net crystal reports issues

If you are going to do reporting with crystal reports  you will face some problems in configuring it.  Follow these steps to minimize the fuss. It took me almost a day to figure these out ...!!

1) Create a Asp.Net Reports website.
2) Add other configuration settings to web.config file. (i.e connection strings, httpmodules...etc)
3) If you are getting the error "Sys.Application' is null or not an object",  Edit theC:\Windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETClientFiles\crystalreportviewers14\js\crviewer\crv.js  as follows
 insted of
if(typeof(Sys)!=='undefined') {

    Sys.Application.notifyScriptLoaded();
}
use
if(typeof(Sys) !== 'undefined' && typeof(Sys.Application) !== 'undefined') {
Sys.Application.notifyScriptLoaded();
}


Note: You can download Crystal Reports runtime for  Visual Studio 2010 from

http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/22083

http://www.businessobjects.com/jump/xi/crvs2010/us2_default.asp

Edit:
 Crystal reports seems to have some incompatibilities with Microsoft Ajax framework. In fact if you put a crystal report viewer inside an update panel it will prompt you various JavaScript errors at run time. So you have find other ways to overcome this such as using third party tools. I am contended with Microsoft Reports which very well suited for my requirements...!!!

Edit
check following link for resolving CR issues after deployment in IIS
http://social.msdn.microsoft.com/Forums/en-CA/vscrystalreports/thread/ef56f72b-7ede-47d8-ba9e-9e63b9ac0203

You might also give a try by referring following links which might aid in resolving all those javascript  and image missing errors I have mentioned before. I did not try these and if anybody got luck with this pls let me know..!!

http://forums.asp.net/t/1693771.aspx/1
http://forums.asp.net/t/1226411.aspx/1
http://social.msdn.microsoft.com/Forums/en-CA/vscrystalreports/thread/ef56f72b-7ede-47d8-ba9e-9e63b9ac0203

Update
It seems to be a common error "Failed to export using the options you specified. Please check your options and try again." when exporting Crystal reports. This happens when the page is posted back and data source is unavailable to the CR viewer. As a workaround follow the instructions given by Mogulla in the following forum.

http://social.microsoft.com/Forums/en/Offtopic/thread/f9ae2910-463e-40f5-92ac-9c29c03c31c3

In addition try following method for printing crystal reports using JavaScript.

http://aspalliance.com/509_Automatically_Printing_Crystal_Reports_in_ASPNET.3

Note: You might have to install CR service packs (3 as most have recommended) before trying these. It seems there are issues with CR SP 4 for VS 2010. Following link provides the available SP s for CR 2010.


http://scn.sap.com/docs/DOC-7824


With a lot of struggle I was finally able to make use of print and export buttons in Crystal reports viewer. Unfortunately you will have to remove any of the update panels used in the page, which indiactes that page refresh will have to be tolerated.The following link will give you some tips on achieving this.
http://www.codeproject.com/Questions/239062/Problem-in-Crystal-Report-toolbar-ASP-Net

cheers

Happy coding.

Tuesday, August 28, 2012

ASP.NET: HttpModule for Query String Encryption

You  can protect URL parameters by using following HttpModule.

If you get the error "Invalid length for a Base-64 char array" when using Convert. FromBase64String(InputString)

Use following:

When Crypted, replace "+" to space.

string encryptString = Convert.ToBase64String(ms.ToArray());

encryptString = encryptString.Replace("+", " ");
http://madskristensen.net/post/HttpModule-for-query-string-encryption.aspx

In addition Scott Mitchel provides a way to implement expiring web pages on your website which can be useful in some situations\
http://aspnet.4guysfromrolla.com/articles/090705-1.aspx

cheers
samitha

implement spell checking with NHun­spell


NHun­spell is a .NET Frame­work Ver­sion of the Open Of­fice spell checker and hy­phen­ation li­brary. It is com­posed by three com­po­nents, the spell checker Hun­spell, the hy­phen­ator Hyphen and the the­saurus MyThes. It is free (LGPL, MPL li­censed), and can be used in closed source projects.

http://nhunspell.sourceforge.net/

cheers
samitha