Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从另一页访问控件。ASP.Net_C#_Html_Asp.net - Fatal编程技术网

C# 从另一页访问控件。ASP.Net

C# 从另一页访问控件。ASP.Net,c#,html,asp.net,C#,Html,Asp.net,嗯,情况就是这样。。。 我在Page1.aspx中有一个元素,我想将它从Page2.aspx管理区更改为用户…,有点 test.InnerText = "testText"; 如何从第二页访问此控件?可能吗 像往常一样,谢谢大家…您需要获取表单的实例。请参阅下面我的两个表单项目 表格一 表格二 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using

嗯,情况就是这样。。。 我在Page1.aspx中有一个元素,我想将它从Page2.aspx管理区更改为用户…,有点

test.InnerText = "testText";
如何从第二页访问此控件?可能吗


像往常一样,谢谢大家…

您需要获取表单的实例。请参阅下面我的两个表单项目 表格一

表格二

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
        Form1 form1;
        public Form2(Form1 nform1)
        {
            InitializeComponent();

            this.FormClosing +=  new FormClosingEventHandler(Form2_FormClosing);
            form1 = nform1;
            form1.Hide();
        }
        private void Form2_FormClosing(object sender, FormClosingEventArgs e)
        {
            //stops form from closing
            e.Cancel = true;
            this.Hide();
        }
        public string GetData()
        {
            return "The quick brown fox jumped over the lazy dog.";
        }

    }
}

好我可以将testText存储在数据库中,并在第2页修改它,在第1页恢复它。但是,还有更好的主意吗?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
        Form1 form1;
        public Form2(Form1 nform1)
        {
            InitializeComponent();

            this.FormClosing +=  new FormClosingEventHandler(Form2_FormClosing);
            form1 = nform1;
            form1.Hide();
        }
        private void Form2_FormClosing(object sender, FormClosingEventArgs e)
        {
            //stops form from closing
            e.Cancel = true;
            this.Hide();
        }
        public string GetData()
        {
            return "The quick brown fox jumped over the lazy dog.";
        }

    }
}