Monday, January 10, 2011

Reporting service-SSRS Report unnecessary page break and keep together

In SSRS reporting, sometime there may be unnecessarily page break contains in your report. This is happening because of keep together option is true. For my case report heading was shown on first page and details was shown on next page because of that option. So what I did was try to change the option to false. Even though I tried in VS2008 it is not effected correctly. So I tried to open the report(rdl) file in notepad and changed the keep together option to false and then I can fixed that unnecessary page break problem. Search all keep together tag and set the value to false.

Handling maxRequestLength setting in MS CRM

By default, maxRequestLength setting is 4Mb in web.config. If you need to upload more than that you can manually change the web.config for MS CRM. Best way is to download IIS administration pack from http://www.iis.net/download/administrationpack and configure from IIS Manager.

After you increase the maxRequestLength you may face the HttpException when you upload more than the limit. HttpException which is saying post size limit. But this exception will throw before it will reach to your code. So you can't handle that Exception by using simple try catch statement.

So how I handle this error is simple override the ProcessRequest method from System.Web.UI.Page which is normally we inherit this class to create ASP.NET web page. Below is the sample code.

//Reading web.config setting
HttpRuntimeSection runTime = (HttpRuntimeSection)WebConfigurationManager.GetSection("system.web/httpRuntime");

//Approx 100 Kb(for page content) size has been deducted because the maxRequestLength proprty is the page size, not only the file upload size
int maxRequestLength = (runTime.MaxRequestLength - 100) * 1024;

if (context.Request.ContentLength < maxRequestLength)
{
base.ProcessRequest(context);
}
else
{
context.Server.ClearError();
context.Response.Redirect("../../_common/error/uploadFailure.aspx?hr=0x80043e08");
}

Don't forget to clear the server error from HttpContext. Otherwise CRM will assume that there is an error and show general error message. But CRM only show error when you turn off DevErrors from web.config. If it is turn on your code will working fine. It cause me to sick one whole day.

Hiding Left Navigation Groups and Toolbar icon

Hiding icon from MS Dynamics CRM toolbar.


HidePaperClip = function() {
var toolBarButtons = document.all.mnuBar1.rows[0].cells[0].childNodes[0].childNodes;
var btnTitle = "Attach a File";
//Loop through each button
for (var i = 0; i < toolBarButtons.length; i++) {
var button = toolBarButtons[i];
if (button.title.match(btnTitle) != null) {
button.nextSibling.style.display = "none";
button.style.display = "none";
}
}
}



Hiding nvaigation group from MS Dynamics CRM's left navigation panel.

HideSubNav = function() {
var nav = document.all.crmNavBar.childNodes;
var count = 0;
for (var i = 0; i < nav.length; i++) {
var li = nav[i];
if (li.className == "ms-crm-Nav-Group") {
if (count!=0) li.style.display = "none";
count++;
}
}
}