Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity: Sitefinity SDK > How do I do conditional Visibility in a widget?

How do I do conditional Visibility in a widget?

  • Posted on Feb 19, 2011 (permalink)

    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

    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Feb 22, 2011 (permalink)

    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!

    Reply

  • Posted on Feb 22, 2011 (permalink)

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

    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Feb 22, 2011 (permalink)

    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!

    Reply

  • Posted on Feb 22, 2011 (permalink)

    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.

    Reply

  • Answer Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Feb 28, 2011 (permalink)

    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!

    Reply

  • Posted on Feb 28, 2011 (permalink)

    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 :)

    Reply

  • Miles avatar

    Posted on Jan 12, 2012 (permalink)

    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).

    Reply

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity: Sitefinity SDK > How do I do conditional Visibility in a widget?