whats wrong with this function?

  • Thread starter Thread starter Goldie
  • Start date Start date
G

Goldie

Can some please look at this function and maybe help me with why it's
not doing as it's told... :)

It's basicall meant to check to see if that field returned from
database actually has any data in it, and if not, return a display:none
style to hide it from the list

I'm trying to achieve not having to show every option of the columns in
that row, especially if the column is empty (no data)

Function code..
-----------------------
Function HideLink ( val )
If field.IsEmpty(val) then
response.write("display:none")
Else
response.write("")
End If
End Function


Use in page
 
First of all, what type is val? Your function doesn't specify it as it is
required to do. Also, this shouldn't be a function unless it is going to
return something. For what you have, you need a Sub.

Lastly, I'm not sure that display:none is what you want. You'd need
STYLE="visibility:hidden" to hide something in the client, not just
display:none.

If val is just a string, then the Sub can be:

Sub HideLink (val As String)
If val ="" then
response.write("STYLE='visibility:hidden'")
Else
response.write("")
End If
End Sub
 
So do i need to define var as a string?
Scott said:
First of all, what type is val? Your function doesn't specify it as it is
required to do. Also, this shouldn't be a function unless it is going to
return something. For what you have, you need a Sub.

Lastly, I'm not sure that display:none is what you want. You'd need
STYLE="visibility:hidden" to hide something in the client, not just
display:none.

If val is just a string, then the Sub can be:

Sub HideLink (val As String)
If val ="" then
response.write("STYLE='visibility:hidden'")
Else
response.write("")
End If
End Sub
 
Sorry, it should be a filename of a pdf (eg 1234.pdf)

Also tried implementing, but i got this error..

Overload resolution failed because no accessible 'ToString' can be
called with these arguments

and thanks for your help too!
 
Do i need to change the way i call it?
Instead of ..

<a href="pdf/<%# Eval("content_type_msds") %>" <%# HideLink (
Container.DataItem("content_type_msds") )%>>MSDS</a>

does it need to be presented some other way?
 
Well, you haven't shown any code that uses the .ToString() method, so is
there more code you haven't provided here?
 
No, you call a function and a sub the same way, but functions must return a
value, sub can not return a value. Since your method doesn't produce a
return value, it should not be a function, it should be a sub.
 
Back
Top