Causing postback

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

In my asp.net application, on click of a button there is some server side code which decides whether a popup window (displayed using showmodaldialog) is to be displayed. If the popup is displayed, on click of OK on the popup, I need some server side code to be executed on the calling page

Could anyone pls tell me how it is possible to execute the server side code on click of ok on the dialog box

Thanks
 
Hi,

Yep, before closing it set its returnValue
window.returnValue = "ok";
close();

on parent/opening page
var res = showModalDialog("BLAH");
if(typeof(res) != "undefined") if(res == "ok" )
document.forms["FORMNAME"].BTNNAME.click();

In this case it will click BTNNAME if returnValue == "ok"

More info
http://msdn.microsoft.com/library/d...hor/dhtml/reference/dhtml_reference_entry.asp

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.icysoft.com/
http://www.microsoft.com/technet/scriptcenter

No matter where you go there you are
==============================
 
Thanks for the reply.

I am doing what you said, but it gives a javascript error - btnTemp (that's the name of the hidden button on my page for which I want to cause the postback) is null or not an object.

This is my javascript

function ShowWindow(Message, Mode)
{
var RetVal = "";
var strPage = document.getElementById("pathfordialog").value + "?DialogMessage=" + Message + "&DialogMode=" + Mode;
RetVal= window.showModalDialog(strPage ,"Alert","edge: Raised; center: Yes; help: no; resizable: no; status: no; dialogWidth:750px; dialogHeight:250px");
if (RetVal == '1')
{
document.forms["Form1"].btnTemp.click();
}
return;
}

btnTemp is a asp.net button control which is hidden.
I am returming values 0,1,2 etc from my modal dialog based on whether buttons ok, yes, no etc are clicked on that page.
 
Hi,

Are you sure the btn is there?
View the source of the page to see if its there
and if it is check for typos, JavaScript is case sensitive

if(document.forms["FORMNAME"].BTNNAME)
{

}
else alert("Btn not found");

Set the btn display/visibility:
style="display:none"....
or
style="visibility:hidden"

--
Best Regards
Vidar Petursson
==============================
Microsoft Visual: Scripting MVP 2000-2004
http://www.icysoft.com/
http://www.deus-x.com/ Instant e-commerce
http://www.microsoft.com/technet/scriptcenter/
Playground: http://213.190.104.211/ ( IE 5.5+ only )

No matter where you go there you are
==============================
 
Back
Top