您需要获取表单的实例。请参阅表格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 Form1 : Form {Form2 form2;public Form1(){ InitializeComponent(); form2 = new Form2(this);}private void button1_Click(object sender, EventArgs e){ form2.Show(); string results = form2.GetData();} }}
表格2
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.';} }}解决方法
好吧,这就是这种情况…我<h2id='test'></h2>在Page1.aspx中有一个元素(),我想从Page2.aspx(用户的管理区域…)中更改它,有点…
test.InnerText = 'testText';
如何从第二页访问此控件?那可能吗?
和往常一样,谢谢大家…