How can I call one of the Control ID's that live inside of a Web user Control?

Posted on 2008-11-10
Last Modified: 2012-05-05
Hi Experts
I have this Line in my aspx page ,which belong to an animated extender:
 <ajaxToolkit:AnimationExtender ID="OpenAnimation" runat="server" TargetControlID="??????"  ...

Also, I have a Web user Control that contain an ImageButton control with this ID="create".

How can I call the ID of this ImageButton and set it up as the TargetControlID from the animation extender in my aspx page?
In other words..How can I make that the program read this:

 <ajaxToolkit:AnimationExtender ID="OpenAnimation" runat="server" TargetControlID="create" ....

This is my page.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MadalPoppUpExtenderExample.aspx.cs"

    Inherits="MadalPoppUpExtenderExample" %>

<%@ Register Src="controls/CreateProfile.ascx" TagName="CreateProfile" TagPrefix="uc1" %>    


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">

<head runat="server">

    <title>Untitled Page</title>

    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />




<body class="hola">

    <form id="form1" runat="server">

        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"/>

        <table border="1" width="450px" height="580px" align="left">



                <uc1:CreateProfile ID="CreateProfile" runat="server"></uc1:CreateProfile>              

                    <asp:HyperLink runat="server"

                              ID="ClickMe" Text="Click Me" NavigateUrl="#">


                    <asp:label runat="server" ID="label1" Text="hollaaa"/>

                    <asp:Panel runat="server" ID="MyPopup" CssClass="modalPopup" Style="display: none; width: 240px">

                        <table bgcolor="blue">


                              <td>This is a test</td>




                                    <asp:TextBox runat="server" ID="Test"/>

                                    <asp:TextBox runat="server" ID="Test2"/>





                    <br />

                    <asp:Button ID="mockPopupTrigger" runat="server" Text="Button" Style="display: none" />


                        ID="ModalPopupExtender" runat="server" 









                    <script type="text/javascript" language="javascript">// Move an element directly on top of another element (and optionally// make it the same size)

                           function Cover(bottom, top, ignoreSize)


                              var location = Sys.UI.DomElement.getLocation(bottom);

                     = 'absolute';

                     = location.y + 'px';

                     = location.x + 'px';

                              if (!ignoreSize)


                         = bottom.offsetHeight + 'px';

                         = bottom.offsetWidth + 'px';








                    <div id="flyout" style="display: none; overflow: hidden; z-index: 2; background-color: green;

                        border: solid 1px red;">


                    <ajaxToolkit:AnimationExtender ID="OpenAnimation" runat="server" TargetControlID="????">






                             <%-- Position the wire frame on top of the button and show it --%>

                                <ScriptAction Script="$find('modalBehavior').hide()" />

                                <ScriptAction Script="Cover($get('create'), $get('flyout'));" />

                                <StyleAction AnimationTarget="flyout" Attribute="display" Value="block"/> 

                            <%-- Move the wire frame from the button's bounds to the info panel's bounds --%>  


                           <Parallel AnimationTarget="flyout" Duration=".3" Fps="25">

                              <Move Horizontal="300" Vertical="350" />

                              <Resize Width="260" Height="280" />

                              <Color PropertyKey="backgroundColor" StartValue="#ffffff" EndValue="#ffffff" />


                           <ScriptAction Script="$find('modalBehavior').show()"/> 

                           <%-- Move the info panel on top of the wire frame, fade it in, and hide the frame --%>

                           <StyleAction AnimationTarget="flyout" Attribute="display" Value="none"/>















This is my web User Control:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CreateProfile.ascx.cs" Inherits="controls_CreateProfile" %>

<table border="1"  bordercolor=red cellpadding="0" cellspacing="0">



        <asp:ImageButton ID="create"  ImageUrl="~/images/CreateProfile.png" runat="server" 






     <asp:ImageButton ID="return"  ImageUrl="~/images/BacktoBcWebsite_On.png" runat="server" />





     <asp:ImageButton ID="ImageButton1"  ImageUrl="~/images/BackToBC.png" runat="server" />




Open in new window

Question by:eddyperu
    LVL 14

    Expert Comment

    I don't think you can directly... at least without some major hack job.

    Instead, just set the TargetControlID to your user control itself, then, add an event that is raised when the button inside the user control is clicked or whatever particular action you're waiting for.
    LVL 4

    Accepted Solution

    Thanks,....I tried that but without any success, Inside my web User Control I have another buttons that also have events. Also, the TargetControl ID only is aksing for a control that trigger it.And it is triggering the AnimationExtender.

    My attempt to do it from codebehind:
    The main problem is when I am  trying to assign the id of the image button to animation extender control at that time during compilation process the user control may not have been loaded . So there is an exception saying control with ID 'create' could not be found . In order to avoid it the best possible way is to load the user control during the Page_init() method so that I can have full control on it during the Load() stage  . Which I DID..but still I have this error:

    Exception Details: System.InvalidOperationException: The TargetControlID of 'OpenAnimation' is not valid. A control with ID 'create' could not be found.

    Thanks for your help

    The aspx from my page:
    public partial class MadalPoppUpExtenderExample : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
            controls_CreateProfile myControl = (controls_CreateProfile)Page.LoadControl("controls/CreateProfile.ascx");
            OpenAnimation.TargetControlID = myControl.MyimageID.ID;
        protected void Page_Init(object sender, EventArgs e)
           controls_CreateProfile myControl = (controls_CreateProfile)Page.LoadControl("controls/CreateProfile.ascx");

    Open in new window


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API ( has made its way into the popular lexicon of the English language.  A few years ago, …
    Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now