How do I do conditional Visibility in a widget?

Posted by Community Admin on 05-Aug-2018 18:30

How do I do conditional Visibility in a widget?

All Replies

Posted by Community Admin on 19-Feb-2011 00:00

What am I doing wrong here...

<asp:Image runat="server" ImageURL='<%# Eval("ImageURL")%>'  Visible= '<%# (String.IsNullOrEmpty(Eval("ImageURL")) ? "False" : "True" %>'  EnableViewState="False"   />

Trying to toggle the visibility of widget content if it's empty...

Doesn't seem to work though...

Also tried to do something similar by conditionally setting the CSS class, but that didn't work either

Posted by Community Admin on 22-Feb-2011 00:00

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

Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

Posted by Community Admin on 22-Feb-2011 00:00

It's the Blog List View, trying to edit the widget template to only show an image if there is one.

Posted by Community Admin on 22-Feb-2011 00:00

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

Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

Posted by Community Admin on 22-Feb-2011 00:00

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.

Posted by Community Admin on 28-Feb-2011 00:00

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

Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

Posted by Community Admin on 28-Feb-2011 00:00

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'll do the text input for now :)

Posted by Community Admin on 12-Jan-2012 00:00

I'm hoping someone will reply soon with an answer to this or at least an update.

The conditional statement would be wonderful if supported (I'm doing the same thing you are with a button). There's no need to write a server side control just to control the visibility (or some property with two values).

Posted by Community Admin on 15-Oct-2013 00:00

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.

This thread is closed