Objectives
This tutorial demonstrates how to refresh server control programmatically without causing full page postback.
- Drag two DropDownList controls into the WebForm and name them ddlMake and ddlModel.
- Drag WebFlyPostBackManager from Toolbox into a WebForm page.

- In code behind, add the following code.
C#
Copy Codeusing ISNet.WebUI.WebDesktop;
public partial class ProgrammaticallyRefresh : System.Web.UI.Page
{
WebFlyPostBackListener listener = null;protected void Page_Load(object sender, EventArgs e)
{
body.Style.Add("overflow", "hidden");
listener = new WebFlyPostBackListener(this);
}
}
- Add some items to ddlMake.

- Add a method to populate data for ddlModel based on the value of ddlMake. Note that you must add WebFlyPostBackMethod() attribute so that the method
can be included in the Metadata collection.
C#
Copy Code[WebFlyPostBackMethod()] public void PopulateModel() { ddlModel.Items.Clear(); if (ddlMake.Text != "- Select a Make -") { for (int i = 1; i <= 5; i++) ddlModel.Items.Add(new ListItem(ddlMake.Text + " Model " + i.ToString(), i.ToString())); } ddlMake.SelectedIndex = 1; WebFlyPostBackManager1.ClientAction.UpdateViewState(); WebFlyPostBackManager1.ClientAction.RenderControl(ddlModel); }
- Add onchange event for ddlMake to call PopulateModel method from client side using WebFlyPostBackManager.
Script
Copy Code<script language="javascript">
function PopulateModel()
{
var fpb = ISGetObject("WebFlyPostBackManager1");
fpb.PopulateModel();
}
</script>
- Set the following properties of WebFlyPostBackManager.
Properties Values ServiceType WebForm ServiceUrl The URL path of the page (in this case, the path is ~/test/ProgrammaticallyRefresh.aspx) PostInputControls True PostViewState True

- Run the page. Select a value from ddlMake and data will be populated in ddlModel without causing full page postback.
