"Page.Clientscript" does not compile in assembly,

J

Jon Paal

"Page.Clientscript" does not compile in assembly, with the error message "Reference to a non-shared member requires an object
reference". ...

what reference is it looking for ??????


class class1
public sub showimg()
Dim Response As HttpResponse = HttpContext.Current.Response
Dim theImage As New object
theImage.ImageUrl = Page.ClientScript.RegisterStartupScript.GetWebResourceUrl(Me.GetType(), "img.gif")
response.write( "<img src=""" & theImage & """>")
end sub
end class
 
R

Riki

Jon said:
"Page.Clientscript" does not compile in assembly, with the error
message "Reference to a non-shared member requires an object
reference". ...
what reference is it looking for ??????


class class1
public sub showimg()
Dim Response As HttpResponse = HttpContext.Current.Response
Dim theImage As New object
theImage.ImageUrl =
Page.ClientScript.RegisterStartupScript.GetWebResourceUrl(Me.GetType(),
"img.gif") response.write( "<img src=""" & theImage & """>") end sub
end class

Replace
theImage.ImageUrl =
Page.ClientScript.RegisterStartupScript.GetWebResourceUrl(Me.GetType(),
"img.gif")
with
theImage.ImageUrl = Page.ClientScript.RegisterStartupScript(Me.GetType(),
"img.gif")

RegisterStartupScript is a function, not a property.
 
J

Jon Paal

I still get the same error message ...

class class1
public sub showimg()
Dim Response As HttpResponse = HttpContext.Current.Response
Dim theImage As New object
theImage.ImageUrl = Page.ClientScript.RegisterStartupScript(Me.GetType(), "img.gif")
response.write( "<img src=""" & theImage & """>")
end sub
end class
 
H

Hans Kesting

"Page.Clientscript" does not compile in assembly, with the error message
"Reference to a non-shared member requires an object reference". ...

what reference is it looking for ??????

class class1
public sub showimg()
Dim Response As HttpResponse = HttpContext.Current.Response
Dim theImage As New object
theImage.ImageUrl =
Page.ClientScript.RegisterStartupScript.GetWebResourceUrl(Me.GetType(),
"img.gif")
response.write( "<img src=""" & theImage & """>")
end sub
end class

Apparently this code is not in an aspx/ascx codebehind, but in an
"external" class. "Page" is not some system-wide global variable, but a
property of the Control class. That is why you can use it there, but
not here. You need to pass a reference to your page to this function.

public sub showimg(MyPage as System.Web.UI.Page)
....
theImage.ImageUrl = MyPage.Register....

Remark 2: I don't know VB that well, but if you declare "theImage" as a
plain "object", does it recognise properties like "ImageUrl" (which is
not a property of "object")?

Remark 3: I'm not sure the line "<img src=""" & theImage & """>" will
give the required result. Why not directly put the URL you get from the
WebResource here?

Hans Kesting
 
J

Jon Paal

Apparently this code is not in an aspx/ascx codebehind, but in an "external" class.

yes this is an assembly class

"Page" is not some system-wide global variable,..

I inherited the page class and now it compiles
Remark 2: I don't know VB that well, but if you declare "theImage" as a plain "object", does it recognise properties like
"ImageUrl" (which is not a property of "object")?

not sure ...

Remark 3: I'm not sure the line "<img src=""" & theImage & """>" will give the required result. Why not directly put the URL you
get from the WebResource here?


I don't know the url of the image as it is stored in the assembly with a unique identifier url
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top