Inside usercontrol I have updatepanelanimationextender, when I add this control to a webpage I want to pass updatepanel’s Id as parameter to control’s property.
Usercontrol:
public partial class Controls_UpdateProgress : System.Web.UI.UserControl
{
public string UpdatePanelID { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
UpdatePanelAnimationExtender1.TargetControlID = UpdatePanelID;
}
}
}
<cc1:updatepanelanimationextender id="UpdatePanelAnimationExtender1" runat="server" >
<Animations>
<OnUpdating>
<Parallel duration="0" >
<ScriptAction Script="onUpdating();" />
</Parallel>
</OnUpdating>
<OnUpdated>
<Parallel duration="0">
<ScriptAction Script="onUpdated();" />
</Parallel>
</OnUpdated>
</Animations>
</cc1:updatepanelanimationextender>
WebPage: UpdatePanel1 is an id of the updatepanel.
<uc1:UpdateProgress ID="UpdateProgress1" runat="server" UpdatePanelID="UpdatePanel1" />
I get error:
The TargetControlID of
‘UpdatePanelAnimationExtender1’ is not
valid. The value cannot be null or
empty.
The AJAX control extenders do not store their
TargetControlIDin theViewState(I checked inSystem.Web.Extensions3.5 with Reflector and that property only gets/sets a private member). Thus, the value you stored is lost on postback.You’ll have to store the value in every request: