Monthly Archives: July 2009

Injecting client script into Infragistics async postback

Often there is a need to add client-side Javascript to the ASP.NET page from server-side code. To perform additional manipulation on rendered controls (hide or disable), to show user an alert message – just a couple of examples. Standard ASP.NET approach is to use page’s client script manager’s  RegisterStartupScript method:

Me.ClientScript.RegisterStartupScript (Type,  Key,  Script, AddScriptTags)

Where

type: The type of the startup script to register.
key: The key of the startup script to register.
script: The startup script literal to register.
addScriptTags: A Boolean value indicating whether to add script tags.

For example:

Me.ClientScript.RegisterStartupScript (Me.GetType(), "alert", "alert('Hello world!');", True)

But if you’re using Infragistics controls that offer async postbacks, like WARP panel or UltraWebTab – there is a problem with this approach.  Since the page doesn’t go through the full postback and doesn’t get destroyed and re-rendered from scratch – this method doesn’t work. Continue reading →

Infragistics WebDataMenu: Expanding context menu UP

Infragistics WebDataMenu is a light-weight highly responsive menu control with rich server and clinet side model. I was using it to display context menu on right mouse click.  The code is pretty simple:

function onMouseClick(oEvent) {
   if (oEvent.button == 2) { //right mouse button clicked
      var menu = $find("xwdmMyMenu");
      menu.showAt(null,null, oEvent);
   }
}

It checks whether the right mouse button was clicked (line 2) then locates the menu object and shows it using showAt method (which accepts 3 parameters, either X and Y client coordinates, or event object from which it derives coordinates of the mouse click).

 It’s all well and good, but the problem is – menu always shows down from the location of the mouse click. And if the click is at the bottom of the screen – menu gets cut off:

I needed to make menu expand UP and  couldn’t find a build-in property or method that would change this behaviour (GroupSettings.ExpandDirection property had no effect). Time for a little hack. Continue reading →

Take a friv break

Tired of all that coding? Take a well deserved break with this fine site, filled with 250+ Flash games combined into unusual one-screen interface:
Friv
So go ahead, visit http://www.friv.co.uk, but heed this warning: many of the games require non-trivial thinking (not to mention they’re highgly addictive).

Infragistics Drag and Drop: detecting element during drag

I was using Infragistics drag-and-drop framework and set an HTML table element as my drop target. Now I needed to know during drag operation over which HTML table cell I am moving. I needed that in order to dynamically change appearance of draggable markup depending on which cell I am currently over.



(Think a strategy game – you’re placing construction on the terrain – if there is enough unoccupied room – the draggable item becomes green, otherwise it remains red).

The solution is to use elemAtPoint property during DragMoveHandler event. Continue reading →

WebDialogWindow – removing IFRAME border in IE

Infragistics WebDialogWindow control is a flexible and lightweight AJAX dialog control designed to look and feel like standard Windows dialogs. One of its neat features – it allows to load the content from an external URL. In that case it renders the content inside of an IFRAME, which is all good and well, but leaves an ugly default iframe border.

Browsers like FireFox can remediate this by simple setting the “frameborder” attribute of the content pane IFRAME element:

function showDialog() {      
    var oDialog = $find('xwdwMyDialog')
    var oDialogContent = oDialog.get_contentPane();
    var oDialogIFrame = oDialogContent.get_iframe();

    // Removing IFRAME border in FireFox
    oDialogIFrame.setAttribute('frameborder', '0');

    oDialog.show();
}

but unfortunatelly this doesn’t work in IE. Continue reading →

Correcting “ASP.NET AJAX client-side framework failed to load” error

If you’re trying to use ASP.NET AJAX features (like Script Manager or Update Panel) in your ASP.NET 3.x website and getting “ASP.NET AJAX client-side framework failed to load” error, chances are your Web.config file is missing required sections. Fastest way to correct this is to create a new ASP.NET website in Visual Studio (you can delete it afterwards) and copy missing sections from the new web.config to the one in your web site.

Update: As churawut pointed out missing .AXD mapping in IIS configuration is another common source of this error (often this is done as security hardening on the IIS).  I encountered it while researching missing images in ASP.NET charts, and found out that underlying reason was missing/corrupt .AXD mapping in IIS.