Wednesday, November 30, 2011

Could not load file or assembly 'Microsoft.ReportViewer.Common

You may come across the above error while configuring and deploying SQL Server Reporting Services. Complete error will look like

Error: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified

Problem: You are missing the installation and configuration info for ReportViewer

Solution: Check the following things

1. Have you installed the Report Viewer? If not you need to download and install it from Microsoft using this link
 
http://www.microsoft.com/downloads/details.aspx?FamilyID=a941c6b2-64dd-4d03-9ca7-4017a0d164fd&displaylang=en
 
2. Reboot the Machine on which you installed the Report Viewer

3. Make sure that following configuration is added in your web.config file

<system.web>
    <httpHandlers>
      <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" />
    </httpHandlers>
</system.web>

Thursday, November 10, 2011

The Controls collection cannot be modified because the control

If you are using ASP.NET and JavaScript, also using some client side code to read Server side variables, you may get an error specially when you put that JavaScript Code inside Head section of the pager or if you are doing a dynamic operation such as exporting the Form’s data to Excel. Your error may look like following

Error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Problem: Page is unable to read the data at client side when server variables are not yet ready.

Solution: Put a Div around your script tag and add runat=”Server”, Example is given below

<div id="Div1" runat="server">
    <script language="javascript" type="text/javascript">
 
        function DoSomething(aValue, bValue) {
            document.getElementById("<%=txtAValue.ClientID%>").value = aValue;
            document.getElementById("<%=txtBValue.ClientID%>").value = bValue;
            document.getElementById("<%=btnShowData.ClientID%>").click();
        }
 
   </script>
</div>