Click here to Skip to main content
14,576,812 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have one div as following

<div>
  <% # IIF(DataBinder.Eval (Container.DataItem,"Specifiction2").ToString()<> "","")
<div>

I want to hide above div when "spcefication2" is blank on .aspx page

how to do it??

What I have tried:

I tried many things but not succeed
Posted
Updated 25-Jun-20 7:34am
Comments
F-ES Sitecore 20-Jun-20 8:24am
   
Hide it using css, or omit the div from the html completely?
Akshay malvankar 20-Jun-20 9:59am
   
how that whats I asking , I want to hide and show depending upon the condition
Maciej Los 22-Jun-20 4:53am
   
"I tried many things but not succeed " - what exactly?
Show your code!
Rate this:
Please Sign up or sign in to vote.

Solution 1

If you want to enable user to show/hide div on client machine, you have to use Javascript. See: Hide and Show DIV using JavaScript[^]

If you want to show/hide div depending on date retrieved from server, please see:
Show/hide elements dynamically in web page[^]
asp.net - How to hide a div from code (c#) - Stack Overflow[^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

The simplest option would be to use a Panel control:
<asp:Panel runat="server" visible='<%# Not String.IsNullOrEmpty(Eval("Specification2", "{0}")) %>'>
    ...
</asp:Panel>
Panel Class (System.Web.UI.WebControls) | Microsoft Docs[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100