Share via


Html.Raw to String?

Question

Thursday, November 8, 2012 1:48 AM

hello,

when we use WYSIWYG Editor, it is necessary to use

Request.Unvalidated("info")

When we want to show it on the page, we use

Html.Raw(row.Info)

But At this point, I want to create a substring from the info. But I cannot convert the Raw to String? What is the best way to do that?

All replies (3)

Thursday, November 8, 2012 2:42 AM âś…Answered

But At this point, I want to create a substring from the info.

row.Info can be treated as a string, so you can use Substring on that:

@Html.Raw(row.Info.ToString().Substring(50))

The problem you might have(depending on what you are trying to achieve) is that row.Info includes HTML as part of the string. So if row.Info was this:

<p>Hello World"</p>

row.Info.ToString().Substring(5) will return "<p>He", not "Hello".


Thursday, November 8, 2012 3:47 AM

I have the problem which you talked about

@Html.Raw(row.Info.ToString().Substring(1,20))

returns

!DOCTYPE html PUBLIC

How can I overcome this problem?


Thursday, November 8, 2012 4:29 AM

I chaged to substring(0, 20)

it worked

thanx