最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ASP.NET高级技术教程
时间:2008-12-18 编辑:简简单单 来源:一聚教程网
好了下面我们来看看在asp.net里面的高级技术教程方面的实例与教程吧.
本教程演示了如何去获得一流的财产价值和调用类的方法与思考。
本教程演示了如何去获得一流的财产价值和调用类的方法与思考。
反思提供了对象(型型)的封装组件,模块和类型。您可以使用反射动态地创建一个实例的类型,绑定的类型现有的物件,或获得类型从现有的对象和调用它的方法或访问其字段和属性。如果您使用的是属性的程式码中,反思使您能够访问它们。
首先,您将需要进口的系统。反思名称
using System.Reflection;
我们使用的是服务器的智慧和发现,到目前为止,他们是最友好,敏感,和有知识的支持团队,我们曾经处理!
在System.Reflection命名空间包含类和接口,提供了一个管理加载鉴于种类,方法和领域,有能力动态地建立和引用类型。
我们使用btnGetProperty_Click获得的财产价值的阶级InstanceClass 。我们使用btnInvoke_Click援引功能getFunction类InstanceClass 。代码如下。
protected string getObjectProperty(string str)
{
try
{
PropertyInfo pi = type.GetProperty("ReturnValue", typeof(string));
retValue = pi.GetValue(o, null).ToString();
catch (Exception ex)
{
return retValue;
}
protected string getOjbectMethod(string str)
{
try
{
MethodInfo mi = type.GetMethod("getFunction", BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(string)},null);
retValue = mi.Invoke(o, new object[] { str });
catch (Exception ex)
{
return retValue.ToString();
}
protected void btnGetProperty_Click(object sender, EventArgs e)
{
}
protected void btnInvoke_Click(object sender, EventArgs e)
{
添加一个自定义类InstanceClass在此为例代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public class InstanceClass
{
public string ReturnValue
{
set { _returnValue = value; }
public InstanceClass()
{
}
public InstanceClass(string str)
{
public string getFunction(string str)
{
}
我们感动我们的网站服务器的智慧和发现他们是难以置信的专业。其安装非常容易,我们启动和运行中没有时间。
前端ReflectionCsharp.aspx页看上去像这样:
PropertyValue: | MethodParameter: | ||
Result: | Result: |
我只是签署了在服务器智力,不能更高兴,我的Windows Server !这里瞧瞧吧,看看吧。
流动的代码隐藏页如下。
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Reflection;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
protected string getObjectProperty(string str)
{
try
{
PropertyInfo pi = type.GetProperty("ReturnValue", typeof(string));
retValue = pi.GetValue(o, null).ToString();
catch (Exception ex)
{
return retValue;
protected string getOjbectMethod(string str)
{
try
{
MethodInfo mi = type.GetMethod("getFunction", BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(string)},null);
retValue = mi.Invoke(o, new object[] { str });
catch (Exception ex)
{
return retValue.ToString();
protected void btnGetProperty_Click(object sender, EventArgs e)
{
protected void btnInvoke_Click(object sender, EventArgs e)
{
}
-
下一个: ASP.NET -服务器控件 实例教程
相关文章
- 理解Asp.Net中WebForm的生命周期 06-20
- asp.net中使用母版制作出的页脚效果 05-17
- ASP.NET在使用X509Certificate2出现问题时的一些解决方法 05-16
- ASP.NET 定时器回调方法的重入 04-20
- 剖析Asp.Net Web API路由系统---WebHost部署方式 04-13
- Asp.net用Button打开另一个的frm的教程 12-26