Blog Posts

Monday, January 31, 2011

Overflow issue in Infragistics WebHtmlEditor

I have a web page with WebHtmlEditor (of the Infragistics with version 10.3.20103). It work fine with browser IE7 but was not showing the scrollbar when the content is more than the window height.  


To fix the issue we can set the CSS style of the TextWindow ( the content editor of the control).  Select the WebHtmlEditor control and in properties window under the 'TextWindow' set the 'CssClass' to your own css class.  In this example I wrote one class - 'infrWebEditor'.  


Identified that when you use the properties window, Visual Studio is generating all the other property tags and was taking time while opening in design mode, instead of setting in the properties window you can copy the below tag in between the <ighedit:WebHtmlEditor> tags -
<TextWindow CssClass="infrWebEditor"/>


And my CSS Class contains the property 'overflow' set to 'auto'. (you can write your own properties to set the control to look as you want).

.infrWebEditor{
    overflow:auto;
}


And the end result is - 


Happy coding.... :-)

Thursday, January 13, 2011

Working around for CA2000 (Microsoft.Reliability) while returning Dataset

While working on a web page I had to get a Dataset from the data access layer and bind the Dataset to my grid in web page.  
I wrote the code in data access layer method - 

   Public Shared Function GetDetails(ByVal strEmpName As String) As DataSet
        Dim dsResult As DataSet = New DataSet()
        Try
           
 ' my code for constructing the command and dataadapter 'da'
 da.Fill(dsResult)
 
        Catch ex As Exception
 
        Finally
 ' some cleanup
        End Try
        Return dsResult
    End Function

Simple but when I compile was getting the warning message - 'CA2000 : Microsoft.Reliability : In method 'GetDetails(String)', call System.IDisposable.Dispose on object 'dsResult' before all references to it are out of scope. xyz.vb'
Without clearing this warning I can not check in. refer 'http://msdn.microsoft.com/en-us/library/ms182289.aspx'. Cause - 'A local object of a IDisposable type is created but the object is not disposed before all references to the object are out of scope.'  The idea behind the CA2000 rule is to free memory when scope is ended.  But what about the object which we need to return to the calling method.  While writing code make sure not to initialize the IDisposable objects; and create/allocate only when returning, so that the method returns the object with proper data only when executed successfully.  In other cases (like exception or no data) return Nothing (null in C#) so that the memory is used effectivily.
For the solution I modified to initialize the DataSet to 'Nothing'
   Public Shared Function GetDetails(ByVal strEmpName As String) As DataSet
        Dim dsResult As DataSet = Nothing
        Try
           
 ' my code for constructing the command and dataadapter 'da'
 da.Fill(dsResult)
 
        Catch ex As Exception
 
        Finally
 ' some cleanup
        End Try
        Return dsResult
    End Function
Later I can check for the Nothing and bind to grid.
   If Not dsResult Is Nothing Then
        'bind to grid
   End If