using a function getting  BC30451 error

duppypog used Ask the Experts™
I'm still coding in VS 2003, ASP.NET 1.1 because I work in the public sector and we have no money for training. I have one line of code, that calls one function that already works perfectly in other applications, but I cannot find one difference to figure out why it's not working here. The code uses a function to return an image.

The .apsx page reads:
<asp:Image Runat="server" Width="100" AlternateText="Photo Unavailable" ImageUrl='<%# GetImg(Container.DataItem("ImageID")) %>' ID="Image1" ></asp:Image>

The Function looks like this:
    Public Function GetImg(ByVal sImg As Object) As String
            With sImg
                If sImg Is DBNull.Value Then
                    sImg = "Imgs\nophoto.gif"
                    sImg = "" & sImg & ".jpg"
                    'Response.ContentType = "image/jpeg"
                End If
            End With
            Return sImg
            lblError.Text = sImg
        Catch ex As Exception
            lblError.Text = ex.ToString
        End Try
    End Function

Does anyone see any reason why this would not work like in the other apps???
Thank you!
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Have you debugged the application to see if actually that function is called or not?

Use some breakpoints and check that.

Also, check if both application has same framework and other configurations/settings.

I don't see why you;re using With sImg.  It serves no purpose there.
gery128 - my development machine's configuration is screwy, so I can't debug on the main machine - I have to copy to the pre-production server for testing, which mimicks the production server. That is where I'm getting the error, but I have no way to step through the code.

edemcs - so you would create the Function as
Public Function GetImg()
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

No, after your Try.

This error seems to occur when compiler doesn't find some element declared.

Can you try this:

<%# ((PageClassName)Container.DataItem).GetImg("ImageID") %>

Also check for syntax.
Check if the function GetImg available in code behind of the page.


Will have to revisit this after I complete the NEW project I was given. I love switching gears mid-stream!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial