How can I not render a button in my view if a given property off my model has no value?
Posted
by Lee Warner
on Stack Overflow
See other posts from Stack Overflow
or by Lee Warner
Published on 2010-06-09T22:36:18Z
Indexed on
2010/06/09
22:42 UTC
Read the original article
Hit count: 209
I'm new to web development. In my view, I want to conditionally show a button if Model.TemplateLocation (which is a string) is not null or empty. Below is the code that is rendering the button currently:
<div class="WPButton MyButton">
<%=Html.ActionLink(Model.TemplateLinkName, "DownloadTemplate", "ExternalData", new ArgsDownloadTemplate { Path = Model.TemplateLocation, FileName = Model.TemplateFileNameForDownload }, new{})%>
</div>
Can I wrap some C# code in the <% %>'s to test for Model.TemplateLocations value before I render that? I was told to look into @style = "display:none" somehow. Could that be what I need?
© Stack Overflow or respective owner