Export (0) Print
Expand All

Controller.Content Method (String)

Creates a content result using a string.

Namespace:  System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

'Declaration
Protected Friend Function Content ( _
	content As String _
) As ContentResult
'Usage
Dim content As String
Dim returnValue As ContentResult

returnValue = Me.Content(content)

Parameters

content
Type: System.String
The content to write to the response.

Return Value

Type: System.Web.Mvc.ContentResult
The content result instance.

The result object that is prepared by this method is written to the response by the MVC framework when the object is executed.

The example in this section shows how to use markup and code to display "Use <b> for bold text" in the browser when the Test Content link is clicked.

The following example shows markup that invokes the TestContent method.

<%= Html.ActionLink("Test Content", "TestContent", 
    new { id = true, sMsg= "Use <b> for bold text"})%> 

The following example shows the TestContent method.

<ValidateInput(False)> _ 
Public Function TestContent(ByVal id As Boolean, ByVal sMsg As String) As ActionResult 
    If id = True Then 
        Return Content(Server.HtmlEncode((sMsg.ToLower()))) 
    Else 
        Return Content(Server.HtmlEncode(sMsg)) 
    End If 
End Function 

Community Additions

Show:
© 2014 Microsoft