Hi, firoz1986
I have created sample code which fullfill your requirement.
HTML
<form id="form1" runat="server">
<div>
<asp:Image ImageUrl="~/Images/00000018.jpg" runat="server" />
<asp:Label ID="lblcharacters" Text="" runat="server" />
</div>
</form>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string s = "I want label to display limited text say 20 char even the data it retrieve from database may be more than 20 char";
lblcharacters.Text = LimitedChar(s);
}
}
private string LimitedChar(string s)
{
string Limitedwords = string.Empty;
string[] words = s.Split();
int wordCount = words.Length;
if (wordCount > 10)
{
return Limitedwords = string.Join(" ", words.Take(10)) + "....";
}
else
{
return Limitedwords = s;
}
}
I hope works for you.