How do I do conditional Visibility in a widget?
What am I doing wrong here...
<
asp:Image
runat
=
"server"
ImageURL='<%# Eval("ImageURL")%>' Visible= '<%# (String.IsNullOrEmpty(Eval("ImageURL")) ? "False" : "True" %>' EnableViewState="False" />
Hi Steve,
If you use our template parser this will not work. Is this a user or custom control compiled to a dll?
Greetings,
Ivan Dimitrov
the Telerik team
It's the Blog List View, trying to edit the widget template to only show an image if there is one.
Hello Steve,
In this case our template parser is used an it does not work with these expressions. You can hide the image with server side code.
Kind regards,
Ivan Dimitrov
the Telerik team
I'm trying to do this without having to build custom controls...
So I think I can do it by adding a new custom field called like ShowImage (bit field) and set that to the visibility property?
Question though is how can I create a bit property...last time I tried it created it as bit(255) and OA killed the site trying to create a bit column with 255 length.
Hello Steve,
If you use Unknown type for the field you can set it to BIT. Another option is True/False field.
Regards,
Ivan Dimitrov
the Telerik team
I'm still having issues with this...if the templates can't do conditional
The only thing I can think to do is expose a textfield whos content is inside a style tag on a div (so I could specify display:none in the textbox)
So that's easy for me to do, but not so easy for an admin to remember (even with the instructional text assigned)
Will the parser ever be expanded to allow the conditional statements?
Visible= '<%# (String.IsNullOrEmpty(Eval("ImageURL")) ? "False" : "True" %>'
I'm hoping someone will reply soon with an answer to this or at least an update.
We're now in version 6.1. Is it possible to do Conditional Visibility? I have created a custom module that has a 'website' field. On my widget template I have a button that says 'visit website' the button will use whatever was entered in the 'website' field as the link. if no website was entered I don't want to show the button. I actually need this functionality on most of my custom modules. Sometimes I need to change the plurality based on what is entered in a field. I need a way to do if/else statements in the template.