Objectives
This tutorial demonstrates the basic function of WebFlyPostBackManager to retrieve simple-type results from a WebForm (aspx) page.
- Drag WebFlyPostBackManager from Toolbox into a WebForm page.
- Create a WebForm in the same directory and named it "WebFormListener.aspx". Add the following code in code behind:
C#
Copy Codeusing System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ISNet.WebUI.WebDesktop;public partial class Samples_WebFlyPostbackManager_WebFormListener : System.Web.UI.Page
{
WebFlyPostBackListener listener = null;protected void Page_Load(object sender, EventArgs e)
{
listener = new WebFlyPostBackListener(this);
}[WebFlyPostBackMethod()]
public string HelloWorld()
{
return "Hello World";
}
}
- Set ServiceType to WebForm and ServiceUrl to WebFormListener.aspx (The URL path of
the page) in the properties box.
- Add a HTML button and name it "Call WebForm Service".
- Add the "OnResponseSuccess" Client Side Events of WebFlyPostBackManager.
- Add the following code in the client-side:
Script
Copy Code<script language="javascript">
function DoClick()
{
var FPBMan = ISGetObject("WebFlyPostBackManager1");
// call the HelloWorld method of the specified ServiceUrl
FPBMan.HelloWorld();
}
function WebFlyPostBackManager1_OnResponseSuccess(controlId, methodName, returnValue)
{
alert("The return value of HelloWorld method is: " + returnValue);
}
</script>
- Invoke DoClick() function in onclick event like the following:
Script
Copy Code<input id="Button1" type="button" value="Call WebForm Service" onclick="DoClick()"/>
- When you click the button, it will retrieve the simple type result from the defined WebForm.
- Run the project and you will see something like following: