Wednesday, March 28, 2012

Crystal Report + VS2010 (ASP.NET) -bobj is undefined

Below is the steps copied from this link.

1. You need to use Web Application Project,No Website Project because Web App will combine DLL to project also.
2. Copy C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13 (you'll got it when you install -CRforVS_redist_install_32bit_13_0.exe)   To your project such as  (ProjectName/crystalreportviewers13)
3. copy this below to your web.config
3.1
<configsections>
    <sectiongroup name="businessObjects">
      <sectiongroup name="crystalReports">
        </sectiongroup></sectiongroup></configsections>

<section name="rptBuildProvider" type="CrystalDecisions.Shared.RptBuildProviderHandler, 
CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, 
PublicKeyToken=692fbea5521e1304, Custom=null">
           <section name="crystalReportViewer" type="System.Configuration.NameValueSectionHandler">
      
3.2
 <businessobjects>
      <crystalreports>
        <rptbuildprovider>
          <add embedrptinresource="true">
        </add></rptbuildprovider>
        <crystalreportviewer>
              <add key="ResourceUri" value="/crystalreportviewers13">
      </add></crystalreportviewer>
      <crystalreports>
    </businessobjects>
Note: in case "/crystalreportviewers13" is not working, try to add "~" symbol.

3.4 Publish your web application with FTP Mode to your any folder,and copy this publish to your web server then TEST it!

My Note:
Another issue with the CR runtime installer is that it always install the necessary web files (such as javascript, icons, etc) to "C:\inetpub\wwwroot\aspnet_client\system_web\2_0_50727". So, if you changed your default IIS web folder to somewhere else, please make sure that you copy "crystalreportviewers13" from the above mention folder to your new IIS web folder.

Reference:
http://social.msdn.microsoft.com/Forums/en-US/vscrystalreports/thread/ef56f72b-7ede-47d8-ba9e-9e63b9ac0203

Monday, March 26, 2012

WebBrowser control tweak

You may tweak the WebBrowser control in case it does not binding to the latest IE version (ie, different from the installed IE).

Below is the registry to be modify:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]
"contoso.exe"=dword:00002328

The values for 'contoso.exe':

9999 (0x270F) - Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
9000 (0x2328) - Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
8888 (0x22B8) -Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.
8000 (0x1F40) - Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.
7000 (0x1B58) - Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.

References:

For discussion, see here:
http://stackoverflow.com/questions/4612255/regarding-ie9-webbrowser-control

For the MSDN reference, see here:
http://msdn.microsoft.com/en-us/library/ee330730%28VS.85%29.aspx#browser_emulation

Thursday, March 8, 2012

Extension method - BETWEEN function

Well, on and off we need to increase the readability of the code and also reduce the typo mistake in the comparison symbols. Here is how you can achieve it:

        public static bool IsBetween(this int value,
            int i,
            int i2)
        {
            return ((value >= i)
                    && (value <= i2));
        }
Now, you may write this code for the integer data type:
        int i = 5;
        if (i.IsBetween(1, 12))
        {
           // the value is between 1 and 12
        }
        else
        {
           // the value is out of range.
        }

By using extension method, you may create IsBetween() method for each data type and also your own data classes.