开发者

about legend tag

In the following legend the text is many characters (long Question) ..What I want is that only first 10 characters of the question be displayed and then dots..something like :-

What is asp.net? What do yo...

How do I do this?

<fieldset style="padding: 10px;">  开发者_如何学JAVA                       
    <legend style="padding: 5px;">
    <b>     
        Question:&nbsp; &nbsp;     
        <%#Eval("Question")%>     
    </b>
    </legend>                      
</fieldset>


In the code behind where you expose the Question property, I'd also expose a TruncatedQuestion like so:

public string TruncatedQuestion
{
    get
    {
         if (Question.Length > 10)
             return Question.Substring(0,10) + "...";
         else
             return Question;
    }
}

Then replace <%#Eval("Question")%> in your code with <%#Eval("TruncatedQuestion")%>


You can perform this via CSS with some proper markup:

HTML:

<fieldset>
   <legend>Question: <% #Eval("Question") %></legend>
</fieldset>

CSS:

fieldset
{
    padding: 10px;
}

legend
{
    padding: 5px;
    width: 10em;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

text-overflow:ellipsis will work in IE7, Safari and Mozilla.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜