Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

ResponseFormat Property

Gets or sets the format of the method response.

Syntax

CSharp

public ResponseFormat ResponseFormat { get; set; }

VisualBasic

Public Property ResponseFormat As ResponseFormat

ManagedCPlusPlus

public:
ResponseFormat ResponseFormat {
	ResponseFormat get ();
	void set (ResponseFormat value);
}

JSharp

/** @property */
/** @property */

Value

Return Value

One of the ResponseFormat values. The default is Json.

Remarks

When the ResponseFormat property is set to Xml, the public fields and properties of the return type that have the ScriptIgnoreAttribute attribute applied will not be ignored because they will be serialized by using the XmlSerializer object instead of the JavaScriptSerializer object. You must apply XmlIgnoreAttribute to make XmlSerializer ignore, or skip, those public fields and properties of the return type.

ResponseFormat will usually be set to Xml when the return type of the method is XmlDocument or XmlElement.

Examples

The following example shows how to apply ScriptMethodAttribute to a Web method with the ResponseFormat property set to Xml. The Web method return value will be serialized as XML and provided to the succeeded callback function as XmlDocument. This code example is part of a larger example provided for the ScriptMethodAttribute class.

CS

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
public XmlDocument GetXmlDocument()
{
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(_xmlString);
    return xmlDoc;
}

VB

<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Xml)> _
Public Function GetXmlDocument() As XmlDocument
    Dim xmlDoc As New XmlDocument()
    xmlDoc.LoadXml(_xmlString)
    Return xmlDoc

End Function 'GetXmlDocument

Assembly: System.Web.Extensions (Module: System.Web.Extensions)