• Home
  • About
  • Resume

Correcting “Object Required” error in Infragistics “this._getContainer=function()” internal code

By , 01/28/2010 5:12 PM

After upgrading to NetAdvantage 9.1 my UltraWebGrid which uses a WebCombo as editor control was starting to throw “Object Required” error inside of Infragistics own JavaScript code in function “_getContainer“. After a bit of experimenting I found out that the error does not happen if I click an existing cell that uses the WebCombo to show the dropdown prior to executing the action that would cause the error.

That lead me to believe that error happens because WebCombo is not initialized in some way and clicking the cell does that initialization. So I tried to simulate that behavior programmatically, by entering and immediately exiting cell edit mode:

// to prevent error - showing and hiding dropdown
var oCell = igtbl_getCellById(sCellId)
oCell.beginEdit();
oCell.endEdit(true);

where sCellId – is ID of any existing cell that uses dropdown as an editor. And Bingo! the error went away. Also beginEdit/endEdit happen so fast, so even though technically they show and hide the dropdown – in reality nothing appears on the screen.

The value of the method attribute may not be html. Solution for the error.

By , 01/19/2010 3:06 PM

If you get the following error while browsing a page in Internet Explorer:

The value of the ‘method’ attribute may not be ‘html’

chances are MSXML registration is corrupted on your machine. To fix this, open DOS prompt and type following commands:

regsvr32 msxml.dll
regsvr32 msxml2.dll
regsvr32 msxml3.dll

This will re-register MSXML and the error will go away.

Using LINQ to bind flat data to Infragistics UltraWebTree

By , 01/10/2010 11:37 PM

Often you have to operate with flattened data that in reality contains multiple levels of hierarchy. For example it can come as a result of several SQL JOIN statement and look like this:

In this example data consist of static root column, region, site, type and state. And the data has clearly defined hierarchy (e.g. Region “India” has site “Bangalore”, site “Bangalore” has types “Application” and “Area”, type “Application” has states “N/A” and “Testing”).

To load this data into Infragistics UltraWebTree I put together a small procedure: Continue reading 'Using LINQ to bind flat data to Infragistics UltraWebTree'»

Serving image from ASP.NET MSChart to external applications via WebService

By , 01/06/2010 4:37 PM

I have an existing ASP.NET application that uses Microsoft Charting control for .NET. I created a CCharting class that hold several methods related to getting data for the chart, applying chart appearance etc. Main method of that class is

Public Sub DrawChart(ByVal i_omsChart As Chart, ByVal i_iChartWidth As Integer, ByVal i_iChartHeight As Integer)

As a 1st parameter it accepts actual chart control from the page, 2nd and 3rd are chart width and height. The method then gets the data for the chart, binds chart to that data, applies chart appearance (colors, series, axises) etc. So drawing a chart is a simple as instantiating the class and calling the method:

Dim oCharting As New CCharting
CCharting.DrawChart(xmsChart,500,300)

where xmsChart is a chart control from HTML markup of the page. The result is displayed on the page:

But now I needed to give access to that chart to external applications, that do not have access neither to chart data nor to Microsoft charting control, may run under different OS’s, be Web apps or not. Continue reading 'Serving image from ASP.NET MSChart to external applications via WebService'»

Delaying SelectedIndexChanged event of ComboBox in VB.NET WinForm

By , 01/06/2010 3:27 PM

A standard situation – ComboBox control of VB.NET WinForm is populated with some data in Form_Load event and index is set to -1 so no item is selected:

Private Sub xfrm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   xCombo.DataSource = GetSomeData()
   xCombo.SelectedIndex = -1
End Sub

Then, when user actually selects an item – SelectedIndexChanged event handler is called to perform action on the selected item:

Private Sub xCombo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xCombo.SelectedIndexChanged
   PerformSomeAction(xCombo.SelectedValue)
End Sub

The problem with this approach is when data is bound in Form_Load – SelectedIndexChanged event handler is also called, and when SelectedIndex is set to -1, SelectedIndexChanged event is called again. Since we expect the SelectedIndexChanged to run only when user selects an item – this behavior may cause unwanted consequences.

The solution is Continue reading 'Delaying SelectedIndexChanged event of ComboBox in VB.NET WinForm'»

PHPBB: Update template file by purging cache

By , 01/05/2010 5:17 PM

Scenario: You’re trying to update a template file in your PHPBB 3.0.x forum, for example to include Google Adsense code into overall_header.html file to display banner on top of all the pages. But after modifying and uploading the file nothing changes, board still displays old template.

What is happening – PHPBB displays cached version of the template. Forum software caches commonly used files to improve performance. The solution is to purge cache.
Purgin Cache in PHPBB 3.0.x board
Login to your forum Administration Control Panel and click Run Now in Purge the cache section. After purging is complete changes in your template take effect.

T-SQL: Automatically Upgrade NVARCHAR(N) field to NVARCHAR(MAX)

By , 01/05/2010 2:36 PM

If you’re writing an SQL upgrade script that updates a field in your table from NVARCHAR(n) data type to NVARCHAR(max) and the script is designed to run many times – an easy way to avoid multiple table alteration is to check for max character length for that field, i.e.:

IF (SELECT CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'MY_TABLE' AND COLUMN_NAME = 'MY_COLUMN')<>-1
BEGIN
	ALTER TABLE [dbo].[MY_TABLE] ALTER COLUMN [MY_COLUMN] [nvarchar](max) NOT NULL
END

This code checks length of the field which is specific number for standard NVARCHAR and -1 for NVARCHAR(max), and alters column type only if it hasn’t already been altered.

T-SQL: Add column with default values to a table

By , 01/05/2010 12:16 PM

Let’s say you need to add a column to an existing table that already contains some rows. And this new column needs to be prepopulated with a default value. For example integer nullable column NEW_COLUMN is added to table MY_TABLE. Common approach is to check for column existence, and if it doesn’t exist – create and populate it:

if not (exists(SELECT * FROM SYSCOLUMNS WHERE ID = OBJECT_ID('[dbo].[MY_TABLE]') AND Name = 'NEW_COLUMN'))
BEGIN
	ALTER TABLE [dbo].[MY_TABLE] ADD [NEW_COLUMN] [int] NULL
	UPDATE [dbo].[MY_TABLE] SET [NEW_COLUMN] = 1
END

But this doesn’t work – you get “Invalid column name” error. The trick is – you don’t need a separate UPDATE statement. ALTER TABLE … ADD statement has a DEFAULT parameter. You can modify previous code like this:

if not (exists(SELECT * FROM SYSCOLUMNS WHERE ID = OBJECT_ID('[dbo].[MY_TABLE]') AND Name = 'NEW_COLUMN'))
BEGIN
	ALTER TABLE [dbo].[MY_TABLE] ADD [NEW_COLUMN] [int] NULL DEFAULT 1 WITH VALUES
END

This ALTER statement assigns default value of 1 to the new column. WITH VALUES parameter is important, it populates existing rows with the default value (without it it will be populated by NULLs).

Happy 2010!

By , 01/01/2010 6:24 PM

My New Year resolution is to make more sense in my code and my blog posts.

Panorama Theme by Themocracy