Hi, having a problem implementing partial page postbacks using a scriptmanager and an update panel. Here is a test page using a web form to call a user control. I am hitting the else statement in the code behind that confirms I do not have a functioning partial post back.
Web Form [TestPartialPage.aspx]:
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Templates/main.Master" CodeBehind="TestPartialPage.aspx.cs" Inherits="BayCare.PreReg.Web.Pages.TestPartialPage" %>
<%@ Register src="../UserControls/TestPartPagePost.ascx" tagname="TestPartPagePost" tagprefix="uc2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<uc2:TestPartPagePost runat="server" />
</asp:Content>
User Control [TestPartPagePost.ascx]:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TestPartPagePost.ascx.cs" Inherits="BayCare.PreReg.Web.UserControls.TestPartPagePost" %>
<%@ Register Assembly="AjaxControlToolkit, Version=3.0.11119.25533, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"
Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:ScriptManager ID="_preRegScriptManager" EnablePartialRendering="true" AsyncPostBackTimeout="200" runat="server" LoadScriptsBeforeUI="false" ScriptMode="Debug" />
<div>
<br /><br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br /><br />
<asp:DropDownList ID="ddl" runat="server" OnSelectedIndexChanged="ddl_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Text="1" Value="1" />
<asp:ListItem Text="2" Value="2" />
<asp:ListItem Text="3" Value="3" />
<asp:ListItem Text="4" Value="4" />
<asp:ListItem Text="5" Value="5" />
<asp:ListItem Text="6" Value="6" />
<asp:ListItem Text="7" Value="7" />
<asp:ListItem Text="8" Value="8" />
</asp:DropDownList>
<asp:UpdatePanel ID="updatePanel" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<asp:Repeater ID="rptr" runat="server">
<ItemTemplate>
<div><%# Container.DataItem %></div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddl" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
Code Behind [TestPartialPage.aspx.cs]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace BayCare.PreReg.Web.UserControls
{
public partial class TestPartPagePost : System.Web.UI.UserControl
{
List<string> data = new List<string>();
protected void Page_Load(object sender, EventArgs e)
{
if (_preRegScriptManager.IsInAsyncPostBack)
{
Label1.Text = "AJAX postback at : " + DateTime.Now.ToString();
}
else
{
Label1.Text = "Not AJAX postback";
}
if (!IsPostBack)
{
for (int i = 0; i < 1; i++)
{
data.Add(string.Format("Item {0}", i));
}
this.rptr.DataSource = data;
this.rptr.DataBind();
this.ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
}
}
protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
// get the number selected
int num = int.Parse(this.ddl.SelectedValue);
for (int i = 0; i < num; i++)
{
data.Add(string.Format("Item {0}", i));
}
this.rptr.DataSource = data;
this.rptr.DataBind();
}
}
}