Monday, January 18, 2010

I am using a text formatting control on asp.net page.?

Actually i am storing this formatting text as HTML into a databse field of Text data type.now i am facing problem in display this text.


i have to show all formatting text on another page. but if length of text is greater than 600 characters, then a link (more ) should be display , and when user clicks on link full html text will be display on page. but the problem is i can not simply use substring to cut the string, becase text is stored with Html tags


for example user enters text=';I am a man'; then it will be stored as ';%26lt;p%26gt;i am a man%26lt;/p%26gt;';, so if i want to display only 10 charcters then substring will return =';%26lt;p%26gt;i am a '; , please help meI am using a text formatting control on asp.net page.?
You need to use two loops for this. Algorithm kind of solution is:





Dim x as string


dim r as int (r = %26lt;number of chars you want to extract%26gt;)


dim i as int (loop counter)


dim h as int (html tag counter)


while i is not equal to r


get a char from input string


if it is a %26lt; char (starting HTML Tag)


while h is not equal to length of string


check the char found. If it is %26gt;, exit from the loop


increment h


end of inner while loop


end if


add the char to x


get next char


increment i


while ends here


Return x.

No comments:

Post a Comment