?
Solved

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

Posted on 2008-11-10
3
Medium Priority
?
1,096 Views
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" ....

Thanks
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
 
 
</head>
<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">
            <tr>
                <td>    
                <uc1:CreateProfile ID="CreateProfile" runat="server"></uc1:CreateProfile>              
                    <asp:HyperLink runat="server"
                              ID="ClickMe" Text="Click Me" NavigateUrl="#">
                    </asp:HyperLink>
                    <asp:label runat="server" ID="label1" Text="hollaaa"/>
                    <asp:Panel runat="server" ID="MyPopup" CssClass="modalPopup" Style="display: none; width: 240px">
                        <table bgcolor="blue">
                            <tr>
                              <td>This is a test</td>
                            </tr>
                            <tr>
                                <td> 
                                    <asp:TextBox runat="server" ID="Test"/>
                                    <asp:TextBox runat="server" ID="Test2"/>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <br />
                    <asp:Button ID="mockPopupTrigger" runat="server" Text="Button" Style="display: none" />
                    <ajaxToolkit:ModalPopupExtender
                        ID="ModalPopupExtender" runat="server" 
                        TargetControlID="mockPopupTrigger" 
                        PopupControlID="MyPopup"
                        DropShadow="true"
                        BackgroundCssClass="modalBackground"                          
                        BehaviorID="modalBehavior">
                    </ajaxToolkit:ModalPopupExtender>
               
 
                    <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);
                              top.style.position = 'absolute';
                              top.style.top = location.y + 'px';
                              top.style.left = location.x + 'px';
                              if (!ignoreSize)
                               {
                                  top.style.height = bottom.offsetHeight + 'px';
                                  top.style.width = bottom.offsetWidth + 'px';
                               }
                            }
                            
 
                    </script>
 
                    
                    <div id="flyout" style="display: none; overflow: hidden; z-index: 2; background-color: green;
                        border: solid 1px red;">
                    </div>
                    <ajaxToolkit:AnimationExtender ID="OpenAnimation" runat="server" TargetControlID="????">
                                      
                        <Animations>
                        <OnClick>
                          <Sequence>
                          
                             <%-- 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" />
                           </Parallel>
                           <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"/>
                         </Sequence>
                      </OnClick>
                      </Animations>
                    </ajaxToolkit:AnimationExtender>
                </td>
            </tr>
        </table>
    </form>
</body>
 
 
 
 
 
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">
  <tr>
    <td>
        <asp:ImageButton ID="create"  ImageUrl="~/images/CreateProfile.png" runat="server" 
        />
    </td>
    </tr>
    <tr>
    <td>
     <asp:ImageButton ID="return"  ImageUrl="~/images/BacktoBcWebsite_On.png" runat="server" />
    </td>
  </tr>
   <tr>
     <td>
     <asp:ImageButton ID="ImageButton1"  ImageUrl="~/images/BackToBC.png" runat="server" />
     </td>
   </tr>
</table>

Open in new window

0
Comment
Question by:eddyperu
2 Comments
 
LVL 14

Expert Comment

by:CyrexCore2k
ID: 22926254
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.
0
 
LVL 4

Accepted Solution

by:
eddyperu earned 0 total points
ID: 22930316
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");
        Page.Controls.Add(myControl);
        OpenAnimation.TargetControlID = myControl.MyimageID.ID;
 
    }
 
    protected void Page_Init(object sender, EventArgs e)
    {
       controls_CreateProfile myControl = (controls_CreateProfile)Page.LoadControl("controls/CreateProfile.ascx");
        Page.Controls.Add(myControl);
    }    
}

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

864 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