Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to transfer values between forms by ASP.NET

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail how to transfer values between forms in ASP.NET. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Suppose there are TextBox1 text boxes and Open buttons on the ParentForm.aspx page

Click the Open button to pop up the SubForm.aspx,SubForm.aspx page with TextBox1 text box and Close button

Click the Close button to close the SubForm.aspx page and display the value of the child page SubForm.aspx text box on the parent page ParentForm.aspx text box.

Foreground code of the parent form:

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

}

Background code of the parent form:

Private void Page_Load (object sender, System.EventArgs e)

{

/ / in the initial phase of the program, we need to know that we are going to enter the hospital.

This.Button1.Attributes.Add ("onClick", "return OpenSubForm ('TextBox1');")

}

Sub-form background code:

Private void Button1_Click (object sender, System.EventArgs e)

{

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]"

}

StrScript = ""

StrScript + = "window.opener." + strRetForm

StrScript + = "." + strRetValue + ".value ='" + this.TextBox1.Text.Trim () + "';"

StrScript + = "window.close ();"

StrScript + = ""

Response.Write (strScript)

}

This is the end of this article on "how to transfer values between ASP.NET forms". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report