showModeldialogbox Postback to same page.

I almost wasted 4 to 5 hours to post back the model dialog to same page. But the solution is very simple.

ADD  <base target=”_self” /> in header field. thats all your showshowModeldialogbox  will work perfect.

Here the sample code

function openSerialWin()
{
var serialtxt = “<%=txtSerialNo.ClientID %>”;
var producttxt = “<%=txtProduct.ClientID %>”;
var SerialNoVal = document.getElementById(“<%=txtSerialNo.ClientID %>”).value;
var ProductVal = document.getElementById(“<%=txtProduct.ClientID %>”).value;
// to handle in IE7
if (window.showModalDialog)
{
var myDialog = new Object;
myDialog.seralNumber =  document.getElementById(serialtxt).value;
myDialog.product = document.getElementById(producttxt).value;
result = window.showModalDialog(‘SerialNumber_scrl.aspx’, myDialog, “dialogHeight:900px,dialogWidth:400px,resizable:no,center:yes” );

if (result==false)
return;
else {
document.getElementById(serialtxt).value = myDialog.seralNumber;
document.getElementById(producttxt).value = myDialog.product;
}
}
// to handle in Firefox
else
{
openWin(‘SerialNumber_scrl.aspx?cntrol1=’ + serialtxt + ‘&cntrol2=’ + producttxt + ‘&SerialNoVal=’ + SerialNoVal + ‘&ProductVal=’ + ProductVal,’ProductsPage’, ‘900’, ‘400’,’200′,’200′,’no’,’no’,’no’,’no’,’yes’);
}

return false;
}

this is code in child window

if (window.showModalDialog)
{
window.returnValue = true;
if (window.dialogArguments != null)
{
window.dialogArguments.seralNumber = cellSerialValue;
window.dialogArguments.product = cellProdValue;
}
window.close();
}
else
{

var query = location.search;
var aValue = query.substring(query.indexOf(“cntrol1=”) + 8, query.indexOf(“&”));
var bValue = query.substring(query.indexOf(“cntrol2=”) + 8, query.indexOf(“&SerialNoVal”));
window.opener.document.getElementById(aValue).value = cellSerialValue;
window.opener.document.getElementById(bValue).value = cellProdValue;
window.close()
}

Thats all .

Advertisements

2 thoughts on “showModeldialogbox Postback to same page.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s