showModalDialog is java script function to open a popup in model window.
Model window means until you fill now close the popup window, you can not work with the parent window.
So the Simplest way is
var Result = window.showModalDialog("popup.aspx","","");
or
var Result = window.showModalDialog("http://google.com","","");
Now if you want to pass query string with URL
var Result = window.showModalDialog("popup.aspx?Name=abc&Age=23","","");
Now how to open Modal Dialog with custom width and height as well as other custom values.
var Result = window.showModalDialog("popup.aspx","Popup","dialogHeight: 300px; dialogWidth: 600px;
dialogTop: 190px; dialogLeft: 220px; edge: Raised; center: Yes;
help: No; resizable: No; status: No;");
Here Result will receive the values from popup.aspx
To return the values from popup page you just have to write a JavaScript code , either on button click, cancel button, close button, save button..
window.returnValue = true;
here it is returning 'true' to parent page.
Now if you have to return multiple values from popup page?
You can write
window.returnValue = 'value1,value2, value3';
and in parent page after receiving these vales in result just split it and store in array and use it.
Result = Result.split(',');
Result[0] will be value1
Result[1] will be value2
Result[2] will be value3
Now How will You return Values from popup C# file ?
just write a java script code in C# and register to page.
ClientScript.RegisterStartupScript(ClientScript.GetType() ,"Search Results", "<script>window.returnValue='value1,value2, value3';window.close();</script>");
0 comments:
Post a Comment