user42348
user42348

Reputation: 4319

Reference to a non shared member requires an object reference

I have added one class under namespace BusinessLogics. I have inherited System.Web.UI.Page to class and showing error as 'end expected' in System.Web.UI.Page

Namespace BusinessLogics
    Public Class BllUploadImages Inherits System.Web.UI.Page
    End Class
End Namespace

How can i remove my error.Can anybody help?

Upvotes: 0

Views: 2036

Answers (1)

Fredrik Mörk
Fredrik Mörk

Reputation: 158289

The Server property is an instance property of the Page class, so you need a Page instance in order to access it. There are a couple of different ways for you to solve this.

It looks like objDesign is of a type that inherits System.Web.UI.Page. Perhaps you can use that instance to invoke the MapPath method:

serverPath = objDesign.Server.MapPath(".") + "\"

One other approach is to fetch the current HttpContext object and use the Server property of that object:

serverPath = HttpContext.Current.Server.MapPath(".") + "\"

Upvotes: 2

Related Questions