Reach control from another page. ASP.Net(从另一个页面到达控制.ASP.NET)
问题描述
Well, this is the situation...
I have a element (<h2 id="test"></h2>
) in Page1.aspx, and I want to change it from Page2.aspx (administration zone for the user...), kind of...
test.InnerText = "testText";
How can I reach this control from the second page? Is that possible?
As usual, thanks you guys...
You need to get an instance of the form. See my two form project below Form 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();
}
}
}
Form 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.";
}
}
}
这篇关于从另一个页面到达控制.ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从另一个页面到达控制.ASP.NET
基础教程推荐
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01