-1
I have that code:
<strong><a <%# Eval("DsPathDocumento") != null && !String.IsNullOrEmpty(Eval("DsPathDocumento").ToString()) ? String.Concat("href='/UpLoads/", Eval("DsPathDocumento"), "'") : "style='cursor: default; color:#000000;'" %>>
<%# Eval("NmTipoDocumento")%>
</a></strong>
I happen to need to apply a javascript, through this class: class="linkUpload"
This class can only happen when I create the hyperlink, otherwise the class cannot be called. My whole attempt to put this class didn’t work. If I put it right after the, like,: <strong><a class="linkUpload" <%# Eval("DsPathDocumento") != null && ...</a></strong>
, when I have document it calls the popup, ok, correct and when I have no link, it also calls the blank popup. He always mounts href, even without attached document, as I discussed here at SOPT. Below my javascript:
$(document).ready(function () {
$('.linkUpload').click(function (event) {
event.preventDefault();
window.open($(this).attr("href"), "popupWindow", "scrollbars=yes");
});
});
The question is: How do I assign javascript to the class only when there is an attached document.
So: If I have attached document, the ternary expression above in the post, must perform the step after the symbol "?" and if there is no attachment, then perform the step after the ":", right? Well, it turns out that anyway and I don’t know why, he’s creating the underline referring to href even when there’s no attachment. I have the "linkUpload" class that should be executed only when there is an attachment. If I put this class right after the "a" tag, it is valid for all situations in the ternary expression, that is, with or without an attachment and I can’t call an expression or html command from within the Asp.Net tags, then generated the post: How do I assign the function only when there is link, ie only when the first part of the ternary expression is executed.
What I want is this, or something similar. I have this Asp.net tag: <% %>
. What would I call this class: class="linkUpload"
within the Asp.net tag?
I tried to do an if to suit better, I think, and I’m not getting it. I tried it in several ways and this way was the last attempt before this post.
<%if(Eval("DsPathDocumento") != null && !String.IsNullOrEmpty(Eval("DsPathDocumento").ToString()))
{ %>
<strong><a class="linkUpload"
<% String.Concat("href='/UpLoads/", Eval("DsPathDocumento"), "'") %>>
</a></strong> <%}%>
<%else
{ %>
"style='cursor: default; color:#000000;'"
Eval("NmTipoDocumento")
<%}%>
I switched to that shape and made the following mistake:
<% if(Eval("DsPathDocumento") != null && !String.IsNullOrEmpty(Eval("DsPathDocumento").ToString()))
{%>
<strong><a class="linkUpload"
<% String.Concat("href='/UpLoads/", Eval("DsPathDocumento"), "'"); %>>
</a></strong> <%}%>
<%else
{ %>
<"style='cursor: default; color:#000000;'">
Eval("NmTipoDocumento")
<%}%>
That is the mistake:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Hello, could explain a little better?
– PauloHDSousa
I made an issue.
– pnet