c# - How to embed an html tag within asp.net label text? -


i trying create hyper link on condition of specific value of database field, news page, , news has content long , in case want create hyper link in case length small no need link, code used:

<asp:label id="lblcontent" runat="server"                          text='<%# string.format("{0}",eval("new_content").tostring().length>150? <a href> eval("new_content").tostring().padright(150).substring(0,150).trimend() + " ..." </a>:eval("new_content")) %>' >                     </asp:label> 

but there error, can have help?

i trying create hyper link

well why not use <asp:hyperlink /> control then?

also don't string use substring() reduce length of text , add ... @ end, use css.

e.g.

<asp:hyperlink id="hlcontent" runat="server" cssclass="trimme"                  text='<%# eval("new_content").tostring() %>'></asp:hyperlink> 

then add css class called trimme

a.trimme{   display: block;     width: 150px;   white-space: nowrap;   overflow: hidden;   text-overflow: ellipsis; } 

take @ this example


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -