Click here to Skip to main content
16,020,114 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi dear,
i am using Ajax's DragPanelExtender.
I have created one user control of this.
I am trying to add this at run time on my master page but only first control is working.
I had checked ids of each control each time they are not repeated.
My code is
User control code

XML
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ACT" %>
<table>
    <tr>
        <td>
            <ACT:DragPanelExtender ID="DPE_TextComments" runat="server" TargetControlID="panel_TextComments"
                DragHandleID="img_Drag">
            </ACT:DragPanelExtender>

            <asp:Panel ID="panel_TextComments" runat="server" BackColor="Snow" Width="250" HorizontalAlign="Center">
                <asp:Panel ID="PanelText" runat="server">
                    <asp:TextBox runat="server" ID="txt_comments" Width="100%" Height="100%" TextMode="MultiLine">
                    </asp:TextBox>
                </asp:Panel>
                <ACT:ResizableControlExtender ID="RCE_Textbox" runat="server" TargetControlID="PanelText"
                    ResizableCssClass="resizingText" HandleCssClass="handleText" OnClientResizing="OnClientResizeText" />
                <%-- <asp:TextBox ID="txt_comments" runat="server"></asp:TextBox>--%>
                <asp:Image ID="img_Drag" runat="server" ImageUrl="~/Images/Drag_Icon.gif" />
            </asp:Panel>
        </td>
    </tr>
</table>



Button Click code
Here PH_Master_Page is place holder on master page and Movable_Text is user control.
li_Count is a static variable incremented each time when new control created

protected void Page_Init(object sender, System.EventArgs e)
    {
        if (li_Count != 0)
        {
            for (int i = 1; i <= li_Count; i++)
            {
                //Utility.RegisterTypeForAjax(typeof(Ajax_CSharp));
                Movable_Text mt = new Movable_Text();
                mt = LoadControl("~/Controls/Movable_Text.ascx") as Movable_Text;
                this.PH_Master_Page.Controls.Add(mt);
            }
        }
    }
    protected void btn_New_Comment_Click(object sender, EventArgs e)
    {
        Create_New_Control();
    }
    public void Create_New_Control()
    {
        try
        {
            Movable_Text mt = new Movable_Text();
            mt = LoadControl("~/Controls/Movable_Text.ascx") as Movable_Text;

            this.PH_Master_Page.Controls.Add(mt);

            li_Count++;
        }
        catch { }
    }


When first DragExtender Panel is added it can moved properly but when next control added it is not moved.
Please please help me for this
Posted
Updated 21-Jun-11 20:02pm
v2
Comments
BobJanova 21-Jun-11 9:04am    
You set a lot of IDs (including target IDs and so on which are not 'ID' attributes) in the user control template. Do those all get substituted for auto-generated unique values at runtime?
Ankur\m/ 22-Jun-11 2:14am    
[moved from comment]
OP replied:
No not actually but i tried by changing their ids also still it was not working .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900