Reputation: 13
I want to hide the text "Apply Online!" below if the applicationURL is null.
<div class='sfitemShortTxtWrp'>
<asp:HiddenField runat="server" ID="hdnApplyURL" Value='<%# Bind("ApplicationURL") %>' />
<a id="cmdApply" href="http://<%# Eval("ApplicationURL")%>" target="_blank" style="font-weight: bold">Apply Online!</a>
</div>
Thanks!
Upvotes: 0
Views: 1869
Reputation: 62301
You can use CSS to hide the hyperlink.
<a id="cmdApply" href="http://<%# Eval("ApplicationURL")%>"
target="_blank"
style="font-weight: bold; <%# string.IsNullOrWhiteSpace(Eval("ApplicationURL").ToString()) ? " display: none": "" %>">
Apply Online!</a>
Upvotes: 1
Reputation: 12295
Jquery version:
var text = $("#cmdApply").attr("href");
if (text == "") {
$("#cmdApply").hide();
}
Upvotes: 1
Reputation: 46077
It would be easier to use a HyperLink
control:
<asp:HyperLink ID="cmdApply" runat="server" Target="_blank" NavigateUrl="..." Text="Apply Now" />
And in the code behind:
cmdApply.Visible = !string.IsNullOrEmpty(cmdApply.NavigateUrl);
Upvotes: 2