Advanced Data Types that is supported by WebFlyPostBackManager are :
- DataSet
- DataTable
- Custom Object that can be serialized
DataSet and DataTable
Due to complexity in DataSet and DataTable , currently WebFlyPostBackManager is only able to map the data.
The data structure at client side will be :
DataSet
+ Tables
+ Rows
+ Cells
DataTable
+ Rows
+ Cells
Custom Object
Custom Object that can be serialized is able to be mapped by WebFlyPostBackManager.
Below is a sample of Custom Object that can be mapped by WebFlyPostBackManager
Custom Object (Server Side)
[Serializable()]
public class CustomClass
{
private int _CustomerID;
private string _CustomerName;
private OrderCollection _Orders;
public int CustomerID
{
get { return _CustomerID; }
set { _CustomerID = value; }
}
public string CustomerName
{
get { return _CustomerName; }
set { _CustomerName = value; }
}
public CustomClass()
{
}
public CustomClass(int customerID, string customerName)
{
_CustomerID = customerID;
_CustomerName = customerName;
}
public OrderCollection Orders
{
get
{
if (_Orders == null) {
_Orders = new OrderCollection();
}
return _Orders;
}
set
{
_Orders = value;
}
}
}
[Serializable()]
public class Order
{
private int _OrderID;
public int OrderID
{
get { return _OrderID; }
set { _OrderID = value; }
}
public Order()
{
}
public Order(int orderID)
{
_OrderID = orderID;
}
}
public class CustomClassCollection : CollectionBase
{
public CustomClassCollection()
{
}
public CustomClass this[int index]
{
get { return ((CustomClass)List[index]); }
set { List[index] = value; }
}
public int Add(CustomClass value)
{
return (List.Add(value));
}
public int IndexOf(CustomClass value)
{
return (List.IndexOf(value));
}
public void Insert(int index, CustomClass value)
{
List.Insert(index, value);
}
public void Remove(CustomClass value)
{
List.Remove(value);
}
public bool Contains(CustomClass value)
{
// If value is not of type TestCustomClass, this will return false.
return (List.Contains(value));
}
protected override void OnInsert(int index, Object value)
{
// Insert additional code to be run only when inserting values.
}
protected override void OnRemove(int index, Object value)
{
// Insert additional code to be run only when removing values.
}
protected override void OnSet(int index, Object oldValue, Object newValue)
{
// Insert additional code to be run only when setting values.
}
protected override void OnValidate(Object value)
{
if (value.GetType() != typeof(CustomClass))
throw new ArgumentException("value must be of type TestCustomClass.", "value");
}
}
With this custom object Class we can have a Method that returns a value with type of CustomClass.
Client
function OnClientClick(controlId, parameter)
{
var FPBMan = ISGetObject("WebFlyPostBackManager1");
FPBMan.GetCustomObject();
}
function WebFlyPostBackManager1_OnGetCustomObject(returnValue)
{
alert("GetCustomObject result: \n" +
"Type = CustomClass\n" +
"obj.CustomerID : type=Int; value=" + returnValue.CustomerID + "\n" +
"obj.CustomerName : type=String; value=\"" + returnValue.CustomerName + "\"\n" +
"obj.Orders : type=Collection; length=" + returnValue.Orders.length + "\n\n" +
"To inspect in more details, please watch the returnValue object in debugger."
);
}
Web Service
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebServiceSamples : System.Web.Services.WebService {
public WebServiceSamples () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public CustomClass GetCustomObject()
{
CustomClass obj = new CustomClass();
obj.CustomerID = 10;
obj.CustomerName = "Blacksmith";
return obj;
}
}
Related Topics
{Overview}
{Features}