This article introduced the ASP.net form to pass the value the method, has the need friend to be possible to consult, hoped has the help to you
Suppose the parentform.aspx page has a TextBox1 text box and an open button
Click the Open button to eject the Subform.aspx,subform.aspx page with the TextBox1 text box and the Close button
Clicking the Close button closes the Subform.aspx page and displays the value of the page subform.aspx text box to the Parentform.aspx text box on the parent page.
Parent form Foreground Code:
Copy Code code as follows:
<script type= "Text/javascript" >
function Opensubform (ret) {
var strpath = "Subform.aspx"
var nheight = 500
var nwidth = 500
var feature
Feature = "height=" + nheight + ", width=" + nwidth + ", top=30,left=30";
feature = ", Dependent=yes,location=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no;";
window.open (strpath+)? Ret_form=form1&ret_value= "+ret, ' subform ', feature). focus ();
return false;
}
</script>
Parent Form Background Code:
Copy Code code as follows:
private void Page_Load (object sender, System.EventArgs e)
{
ページを initial するユーザーコードをここに 挿 into します
this. BUTTON1.ATTRIBUTES.ADD ("OnClick", "Return Opensubform (' TextBox1 ');");
}
Sub-form Background code:
Copy Code code as follows:
private void Button1_Click (object sender, System.EventArgs e)
& nbsp; {
String Strscript =string. Empty;
string strretform = String.Empty;
string Strretvalue=string.empty;
strretform=request.params["Ret_form"];
strretvalue=request.params["Ret_value"];
if (strretform = string. Empty)
{
strretform= "document.forms[0]";br> }
strscript = "<script language=javascript>";
Strscript + = "Window.opener." + strretform;
Strscript + + + Strretvalue + ". Value= '" + This. TextBox1.Text.Trim () + "';";
Strscript + = "window.close ();";
Strscript + = "</script>";
Response.Write (strscript);
}