0

Here is my code for repeater,

 <asp:Repeater ID="Repeater1" runat="server" DataSourceID="NewDataSource">
        <ItemTemplate>
               <%# Eval("Title") %><br />
               <%# Eval("PostDate","{0:dd-MMM-yyyy}")%><br/>
               <%# Eval("Body") %><br />
            <hr />
        </ItemTemplate>
    </asp:Repeater>

In my data , Body is html string and I want to substring this not including html tags !

Example

If Body string is likes
<span style="color: #996600">Detail </span>of my Body <span style="color: #669933">Text </span>

I want to show likes ,

<span style="color: #996600">Detail </span>of my <span style="color: #669933"> </span>... ReadMore(to navigate detail Page)

I found javascript function to do it in Substring text with html tags in javascript

But I don't know how to use with my code ! Kindly , help me , Thanks ! :)

2 Answers 2

0

Why substring?

You can use css to control the words, and set the title to the full text at the same time.

.ellipsis-body{
    white-space: nowrap;
    overflow: hidden;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
}

Hopes to help you.

Sign up to request clarification or add additional context in comments.

1 Comment

You need to set a width firstly.
0

You should be able to do something like this...

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="NewDataSource">
    <ItemTemplate>
           <%# Eval("Title") %><br />
           <%# Eval("PostDate","{0:dd-MMM-yyyy}")%><br/>
           <%# Regex.Replace(Eval("Body").toString(), "<.*?>", "").Substring(0, 10) & " ..." %> 
           <a href="">Read More</a><br />
        <hr />
    </ItemTemplate>
</asp:Repeater>

4 Comments

Thanks Luke , but your code will substring all including html tags .I found the solution at the link refer in my question , but I just don't know how to use with my code !
you found a code in JS but you write currently in asp net C# or VB. Please see my update, where you can simply remove all html tags.
But I don't want to remove html tag :)
Here jsfiddle.net/danmana/5mNNU , that's what I want to do . But I don't know how to implement this javascript in my code :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.