.NET Performance Blog

April 28, 2006

ObjectDataSource: UpdateParameters ignored if DataObjectTypeName is used

Filed under: .NET,Bug Fix — Eric P @ 2:28 pm

If you specify 'DataObjectTypeName' parameter in ObjectDataSource — UpdateParameters get ignored. So if you have:

<asp:ObjectDataSource ID="objectDataSource" runat="server"

DataObjectTypeName="Customer" InsertMethod="Save"
UpdateMethod="Save"
DeleteMethod="Delete"
SelectMethod="LoadList"
TypeName="CustomerLogic">

<UpdateParameters>

<asp:Parameter Name="CategoryID" DefaultValue="5"/>

</UpdateParameters>

</asp:ObjectDataSource>

When you do update — parameter 'CategoryID' is not bind to Customer.CategoryID.

The solution to this problem is to add parameters dynamically in Updating event handler:

protected void objectDataSource_Updating(object sender, ObjectDataSourceMethodEventArgs e)

{

Customer customer=(Customer)e.InputParameters[0];

customer.CategoryID=5;

}

April 12, 2006

Bug Fix: SELECT box displayed through Dynamic DIV in Internet Explorer

Filed under: Bug Fix — Eric P @ 9:05 am

There is a common bug that occurs when there is DIV (with absolute positioning) being displayed in front of SELECT html control. The SELECT control stays visible even with the div over it. It has to do with windowed controls (like SELECT) taking Z-Index precedence over any non-windowed control. The bug only occurs in Internet Explorer. To read more about it check out the following link

I create an example that contains both the bug and the fix at
this url.

The Fix
To fix the issue I basically create a new IFrame with the same dimensions and at the same position as Popup Div. Then I store IFrame object in a variable so I can destroy it when div is hidden.

Here is the complete code:

<script language="javascript">
<!–

var g_PopupIFrame;

function IsIE()
{

return ( navigator.appName=="Microsoft Internet Explorer" );

}

function HidePopupDiv(divID)
{

var divPopup;
divPopup=document.getElementById(divID);
divPopup.style.visibility = "hidden";

if (IsIE())
{

document.body.removeChild(g_PopupIFrame);
g_PopupIFrame=null;

}

}

function ShowPopupDiv(divID)
{

var divPopup=document.getElementById(divID);

if (!IsIE())
{

//Just display the div
divPopup.style.visibility ="visible";
return;

}

//Increase default zIndex of div by 1, so that DIV appears before IFrame
divPopup.style.zIndex=divPopup.style.zIndex+1;

var iFrame = document.createElement("IFRAME");
iFrame.setAttribute("src", "");

//Match IFrame position with divPopup
iFrame.style.position="absolute";
iFrame.style.left =divPopup.offsetLeft + 'px';
iFrame.style.top =divPopup.offsetTop + 'px';
iFrame.style.width =divPopup.offsetWidth + 'px';
iFrame.style.height =divPopup.offsetHeight + 'px';

document.body.appendChild(iFrame);

//Store iFrame in global variable, so it can get removed when divPopup is hidden g_PopupIFrame=iFrame;
divPopup.style.visibility ="visible";

}

//–>
</script>

Issue With SSL

There is an issue using IFrame with src="" on SSL pages. User will get a security warning whenever popup div is displayed and IFrame is created. Full description of the issue is here.

To work around this problem create an empty html page – "Blank.htm". Then replace line

iFrame.setAttribute("src", "");

with

iFrame.setAttribute("src", "/Blank.htm");

//Use correct absolute path for Blank.htm

Blog at WordPress.com.