To pop the custom dialog box in the Web.
Last Update:2017-02-28
Source: Internet
Author: User
Main Web pages:
private void Page_Load (object sender, System.EventArgs e)
{
String strscript= "<script language=\" javascript\ ">\n"
Returns-------------------------------------------------a single value
Strscript + = "function GetValue (infoa,infob) {\ n";
Strscript + = "var Strid=window.showmodaldialog" (' Popforms/testpop.aspx? Parama= ' +infoa+ ' ¶mb= ' +infob,null, ';
Strscript = "' Dialogwidth:450px;dialogheight:480px;center:1;scroll:1;help:0;status:0;resizable:no; ') \ n ";
Strscript + = "if (strid!=undefined) \ document.all['" + Txttext.clientid + "'].value=strid;\n"; The result Strid the value to TxtText
Strscript + = "}\n"; If you return the numbers,
------------------------------------------------Multi-value return
Sbscript.append ("function openeditlot () {\ n");
Sbscript.append ("var strid=window.showmodaldialog" (' Popforms/test.aspx?mytime= ' +date (), NULL, ");
Sbscript.append ("' Dialogwidth:433px;dialogheight:450px;center:1;scroll:1;help:0;status:0;resizable:no; ') \ n ");
Sbscript.append ("if (strid!=undefined) {document.all['" + Txta.clientid + "'].value=strid[0]\n");
Sbscript.append ("document.all['" + Txtb.clientid + "'].value=strid[1]\n");
Sbscript.append ("document.all['" + Txtc.clientid + "'].value=strid[2]\n}");
Sbscript.append ("}\n");
More and here ....
//-------------------------------------------------
Strscript = "</script>";
This. Page.registerclientscriptblock ("ClientScript", strscript);
if (! IsPostBack)
{
btntest.attributes["onclick"] = "GetValue" (document.all (' "+txta.clientid+"). Checked,document.all (' "+
Txtb.clientid+ "'). Value)";
}
}
Bounce out of Web pages:
The definition of the return function in 1.HTML for adjusting the return function in the page
<HEAD>
<title>QueryLot</title>
<meta name= "generator" content= "Microsoft Visual Studio 7.0" >
<meta name= "Code_language" content= "C #" >
<meta name= "vs_defaultClientScript" content= "JavaScript" >
<meta name= "vs_targetschema" content= "http://schemas.microsoft.com/intellisense/ie5" >
<link href= ". /.. /webcontroler/icmes.css "type=" Text/css "rel=" stylesheet ">
<base target= "_self" >
<script language= "JavaScript" >
Function ReturnValue (PAMA,PAMB,PAMC)
{
var my_array = new Array (PamA, PAMB,PAMC);
Window.returnvalue = My_array;
Window.close ();
}
</script>
</HEAD>
2. Adjust the return function in the page
Use the push button to return
private void Page_Load (object sender, System.EventArgs e)
{
if (! IsPostBack)
{
btnreturn.attributes["onclick"] = "returnvalue" (' +valuea+ ", '" +valueb+ ", '" +valuec+ ")";
}
}
Use the DataGrid Click to return
private void Dbgrid_itemdatabound (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (E.item.datasetindex!=-1)
{
E.item.cells[0]. attributes["onclick"] = "returnvalue" (' +e.item.cells[0]. text+ "', '" "+e.item.cells[1]. text+ "', '" +
E.ITEM.CELLS[2]. text+ "')";
E.item.cells[0]. CssClass = "";//referencing a CSS file for point-click
}
}
3. Return with no return value
private void Btncancel_click (object sender, System.EventArgs e)
{
Response.Write ("<script language=javascript> window.close (); </Script> ");
}