SmartNavigation with Metabuilders Combobox

I ran into a little problem trying to integrate Metabuilders combobox into an asp.net web app I am creating.

The problem was that the onload event handler was not properly firing when smartNav was turned on.

The “InitScript” was as follows:

if ( typeof( window.addEventListener ) != "undefined" ) {
    window.addEventListener("load", ComboBox_Init, false);
    alert('case 1');
} else if ( typeof( window.attachEvent ) != "undefined" ) {
    window.attachEvent("onload", ComboBox_Init);
} else {
    ComboBox_Init();

}

Well when you are using smartNav, the window.onload event is only fired the first time you reach the page.  So I used this bit of C# in the control to get it to work.

String initScript = resources.GetString("InitScript");
if (this.Page.SmartNavigation)
{
this.Page.RegisterStartupScript("MetaBuilders.WebControls.ComboBox Init with Smartnav", "<script>ComboBox_Init();</script>");
}
else
{
this.Page.RegisterStartupScript("MetaBuilders.WebControls.ComboBox Init", initScript);
}

 

Advertisement

One thought on “SmartNavigation with Metabuilders Combobox

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s