|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
"Page.Clientscript" does not compile in assembly,"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 Jon Paal wrote:
Show quote > "Page.Clientscript" does not compile in assembly, with the error Replace> 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 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. -- Riki 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
Show quote
> "Page.Clientscript" does not compile in assembly, with the error message Apparently this code is not in an aspx/ascx codebehind, but in an > "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 "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 |
|||||||||||||||||||||||