Class XFormData
Value holder for XForms data and metadata.
Inheritance
Implements
Inherited Members
Namespace: EPiServer.XForms
Assembly: EPiServer.XForms.dll
Version: 9.12.2Syntax
public class XFormData : IItem
Remarks
XForm data is stored in the following syntax in an XmlDocument:
<instance> <Vote>Really great</Vote> </instance>
Examples
Example on how to save XFormData to the database
XForm form = new XForm();
XFormData data = form.CreateFormData();
NameValueCollection values = data.GetValues();
foreach(String key in values)
{
data.SetValue(key, "abc");
}
data.ChannelOptions = ChannelOptions.Database;
data.Send();
Constructors
XFormData()
Declaration
public XFormData()
Fields
ChannelName
The unique name that is used when sending form data.
Declaration
public readonly string ChannelName
Field Value
Type | Description |
---|---|
System.String |
Properties
ChannelOptions
Gets of sets the Channels that the form data should be sent to.
Declaration
public ChannelOptions ChannelOptions { get; set; }
Property Value
Type | Description |
---|---|
ChannelOptions |
Remarks
See ChannelOptions for a list of options.
CustomUrl
A url that is used to send data to when sending form data with ChannelOptions.CustomUrl.
Declaration
public string CustomUrl { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Data
The xml node containing the form data.
Declaration
public SerializableXmlDocument Data { get; set; }
Property Value
Type | Description |
---|---|
SerializableXmlDocument |
DatePosted
The date that the form data was posted.
Declaration
public DateTime DatePosted { get; set; }
Property Value
Type | Description |
---|---|
System.DateTime |
FormId
The id for the form that created the form data.
Declaration
public Guid FormId { get; set; }
Property Value
Type | Description |
---|---|
System.Guid |
Id
Declaration
public object Id { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
IsNull
Declaration
public bool IsNull { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
MailFrom
An e-mail address that is used for sending e-mail.
Declaration
public string MailFrom { get; set; }
Property Value
Type | Description |
---|---|
System.String |
MailSubject
A subject that is used for sending e-mail.
Declaration
public string MailSubject { get; set; }
Property Value
Type | Description |
---|---|
System.String |
MailTo
An e-mail address that is used for sending e-mail.
Declaration
public string MailTo { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Name
Gets the Internal data layer name for the XForm.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
PageGuid
The guid of the page that the form is posted from.
Declaration
public Guid PageGuid { get; set; }
Property Value
Type | Description |
---|---|
System.Guid |
Remarks
This can be used when searching through form data.
StorageId
The storage Identity of the XFormData object
Declaration
public Identity StorageId { get; set; }
Property Value
Type | Description |
---|---|
Identity |
UserName
The name of the user that is posting the form.
Declaration
public string UserName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
CreateInstance(Guid, Guid)
Loads an XFormData object.
Declaration
public static XFormData CreateInstance(Guid formDataId, Guid formId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | formDataId | The id for the XFormData to load. |
System.Guid | formId | The id of the XForm the post belongs to |
Returns
Type | Description |
---|---|
XFormData | The loaded XFormData object. |
CreateStore(Guid, IDictionary<String, Type>, StoreDefinitionParameters)
Returns the DynamicDataStore instance that the XFormData is stored
Declaration
public static DynamicDataStore CreateStore(Guid formId, IDictionary<string, Type> typeBag, StoreDefinitionParameters parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | formId | The id of the XForm the posts belong to |
System.Collections.Generic.IDictionary<System.String, System.Type> | typeBag | The definition of the store |
StoreDefinitionParameters | parameters | The StoreDefinitionParameters to use when mapping the store |
Returns
Type | Description |
---|---|
DynamicDataStore | A DynamicDataStore instance |
Delete()
Deletes the object from the data layer.
Declaration
public void Delete()
GetFilteredValues(HtmlFilter)
Get all values for the XFormData object which have been filtered by the supplied filter.
Declaration
public NameValueCollection GetFilteredValues(HtmlFilter filter)
Parameters
Type | Name | Description |
---|---|---|
HtmlFilter | filter | A HtmlFilter to use to filter the values |
Returns
Type | Description |
---|---|
System.Collections.Specialized.NameValueCollection | A NameValueCollection containing the keys/values for the form data. |
GetInstanceDataAttribute(String, String)
Returns the value for an attribute for an node under the instance node.
Declaration
public string GetInstanceDataAttribute(string dataKey, string attributeKey)
Parameters
Type | Name | Description |
---|---|---|
System.String | dataKey | The node name. |
System.String | attributeKey | The attribute name. |
Returns
Type | Description |
---|---|
System.String | The value for the attribute. If the attribute does not exist String.Empty will be returned. |
GetStore(Guid)
Returns the DynamicDataStore instance that the XFormData is stored
Declaration
public static DynamicDataStore GetStore(Guid formId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | formId | The id of the XForm the posts belong to |
Returns
Type | Description |
---|---|
DynamicDataStore |
GetStoreName(Guid)
Gets the name of the store where postings from specified form is stored..
Declaration
public static string GetStoreName(Guid formId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | formId | The form id. |
Returns
Type | Description |
---|---|
System.String |
GetValue(String)
Get the value for a given node.
Declaration
public string GetValue(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The name of the node. |
Returns
Type | Description |
---|---|
System.String | The value for the node. |
GetValues()
Get all values for the XFormData object.
Declaration
public NameValueCollection GetValues()
Returns
Type | Description |
---|---|
System.Collections.Specialized.NameValueCollection | A NameValueCollection containing the keys/values for the form data. |
HasAlreadyPosted(HttpCookieCollection)
Declaration
public bool HasAlreadyPosted(HttpCookieCollection cookieCollection)
Parameters
Type | Name | Description |
---|---|---|
System.Web.HttpCookieCollection | cookieCollection |
Returns
Type | Description |
---|---|
System.Boolean |
HasAlreadyPosted(Page)
Check if the current user has already posted the form.
Declaration
public bool HasAlreadyPosted(Page page)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Page | page | The executing page. |
Returns
Type | Description |
---|---|
System.Boolean | True if the user has posted the form, false otherwise. |
Save()
Save the XFormData directly to the database.
Declaration
public void Save()
Save(DbTransaction)
Save the XFormData directly to the database.
Declaration
[Obsolete("Saving XFormData no longer supports passing in a database transaction. Wrap the call in a EPiServer.Data.IDatabaseHandler.ExecuteTransaction action method for explicit transaction support.", false)]
public void Save(DbTransaction transaction)
Parameters
Type | Name | Description |
---|---|---|
System.Data.Common.DbTransaction | transaction |
SaveEventHandler(Object, ChannelEventArgs)
Handler method for the SendEvent This method is not intended to be called by user code
Declaration
public static void SaveEventHandler(object sender, ChannelEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | The sender of the event |
ChannelEventArgs | e | The channel event arguments |
Send()
Sends the form data to the channel(s) defined in ChannelOptions.
Declaration
public void Send()
Send(Guid)
Sets the FormId property and sends the form.
Declaration
public void Send(Guid formId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | formId | The form to save the data for |
SetInstanceDataAttribute(String, String, String, String)
Updates or sets the value for an attribute for an node under the instance node.
Declaration
public void SetInstanceDataAttribute(string dataKey, string attributePrefix, string attributeKey, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | dataKey | The node you want to update. |
System.String | attributePrefix | The prefix for the attribute. |
System.String | attributeKey | The name for the attribute. |
System.String | value | The value you want to set. |
SetPostedCookie(Guid, Page)
Creates a cookie that is added to the Page that indicates that the form has been posted.
Declaration
public void SetPostedCookie(Guid formId, Page page)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | formId | The id for the form. |
System.Web.UI.Page | page | The executing page used to set the cookie for. |
SetValue(String, String)
Set a value for a given key.
Declaration
public void SetValue(string key, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key of the node. |
System.String | value | The value to set. |
Remarks
If the node for the key does not exists it is added to the document.