访问类中的网页中定义的对象 [英] Accessing an object defined in a webpage in a class
本文介绍了访问类中的网页中定义的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想访问在类中的网页(页面加载时)中定义的对象.我该怎么办..请不要告诉我使用状态管理.
我正在使用VS 2008
问候.
Hi all,
I want to access an object defined in a web-page(on page load) in a class. How can i do that..Please dont tell me to use state management.
I am using VS 2008
Regards.
推荐答案
您可以将对象从网页传递到类中.例如,如果您想使用单独的类来操作文本框中的文本,则可以执行以下操作:
You can pass the object from your webpage into the class. For example, if you wanted to manipulate the text in a textbox using a separate class you could do something like this:
public class TextBoxHelper
{
public void TextBoxContentsToUpper(TextBox t)
{
t.Text = t.Text.ToUpper();
}
}
假设您的网页上有一个ID为"Name"的TextBox,则从您的网页中调用类方法,如下所示:
assuming your webpage has a TextBox with ID "Name" call the class method from your webpage like this:
var helper = new TextBoxHelper();
helper.TextBoxContentsToUpper(Name);
这篇关于访问类中的网页中定义的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文