This topic is locked

Default value for image type field

8/13/2012 11:27:28 PM
ASPRunnerPro General questions
A
admin author

Hi,
How can we assign default value for a image type field, i mean if image is not uploaded in that field then it should show a dummy default image.
Sami

Sergey Kornilov admin 8/14/2012

This is not possible via default value however you can try to use events for this purpose.
I assume that field name is Image, this is a text field that stores file name. Add the following code to BeforeAdd event:

if values("Image")="" then

values("Image")="default.jpg"

end if
A
admin author 8/14/2012

Thanks Sergey,
but it's not working as i am using MS SQL Server and this field data type in sql server is 'image'
also if i am not selecting any image then it throws following error
[Microsoft][SQL Server Native Client 10.0]Invalid string or buffer length
Sami

Sergey Kornilov admin 8/15/2012

If you store images directly in the database - this trick won't work for you. Probably you can use 'View as' type 'Custom', check if field contains any data and display a default image if field is NULL.