对象引用是所必需的非静态字段,方法或财产 [英] An object reference is required for the non-static field, method, or property

查看:121
本文介绍了对象引用是所必需的非静态字段,方法或财产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建我的VS2008 .NET 3.5的时候解决方案收到一封错误 错误1,需要一个对象引用非静态字段,方法或属性System.Web.UI.Page.Request.get

I recieve an error when building my vs2008 .net 3.5 solution Error 1 An object reference is required for the non-static field, method, or property 'System.Web.UI.Page.Request.get'

String _XSLTPath = Page.Request.Url.Scheme 
    + "://" 
    + Page.Request.Url.Authority 
    + Page.Request.ApplicationPath.TrimEnd('/') 
    + '/' 
    + "webparts/weatherandtime/weather/xslt/RSSWeatherXSL.xsl";

Page对象似乎绿灯,被higlighting这不是我想要的。可有人怎么回事解释一下吗?

The Page object seems to be higlighting in green which is not what i want. Can someone explain whats going on?

谢谢

推荐答案

您尝试访问非静态属性 Page.Request 没有一个实例。你必须把它的一个实例。像 myPage.Request

You try to access the non-static property Page.Request without an instance. You have to call it on an instance. Something like myPage.Request.

这篇关于对象引用是所必需的非静态字段,方法或财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆