Add multiple ajax control runtime but only first working

Posted by Vivek.deshmukh under C# on 6/21/2011 | Points: 10 | Views : 1802 | Status : [Member] | Replies : 2
Hi ,

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 they are not repeated.
My code is
User control code
<%@ 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.

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 guide me for this




Responses

Posted by: Vivek.deshmukh on: 6/22/2011 [Member] Starter | Points: 25

Up
0
Down
//if (li_Count > 0)
//{

// //mt.ID = "Movable_Text" + Convert.ToString(li_Count);

// DragPanelExtender drag_panel = new DragPanelExtender();
// drag_panel = mt.FindControl("DPE_TextComments") as DragPanelExtender;
// drag_panel.ID = "drag_panel" + Convert.ToString(li_Count);


// System.Web.UI.WebControls.Panel panel_TextComments = new System.Web.UI.WebControls.Panel();
// panel_TextComments = mt.FindControl("panel_TextComments") as System.Web.UI.WebControls.Panel;
// panel_TextComments.ID = "panel_TextComments" + Convert.ToString(li_Count);

// System.Web.UI.WebControls.Panel PanelText = new System.Web.UI.WebControls.Panel();
// PanelText = mt.FindControl("PanelText") as System.Web.UI.WebControls.Panel;
// PanelText.ID = "PanelText" + Convert.ToString(li_Count);

// System.Web.UI.WebControls.TextBox txt_Comments = new System.Web.UI.WebControls.TextBox();
// txt_Comments = mt.FindControl("txt_Comments") as System.Web.UI.WebControls.TextBox;
// txt_Comments.ID = Convert.ToString("txt_Comments") + Convert.ToString(li_Count);

// //PanelText.Controls.Add(txt_Comments);


// ResizableControlExtender RCE_Textbox = new ResizableControlExtender();
// RCE_Textbox = mt.FindControl("RCE_Textbox") as ResizableControlExtender;
// RCE_Textbox.ID = Convert.ToString("RCE_Textbox") + Convert.ToString(li_Count);

// RCE_Textbox.TargetControlID = "PanelText" + Convert.ToString(li_Count);
// //RCE_Textbox.HandleCssClass = "handleText";
// //RCE_Textbox.OnClientResize = "OnClientResizeText";
// //RCE_Textbox.ResizableCssClass = "resizingText";


// System.Web.UI.WebControls.Image img_Drag = new System.Web.UI.WebControls.Image();
// img_Drag = mt.FindControl("img_Drag") as System.Web.UI.WebControls.Image;
// img_Drag.ID = "img_Drag" + Convert.ToString(li_Count);
// img_Drag.ImageUrl = "~/Images/Drag_Icon.gif";

// ////panel_TextComments.Controls.Add(RCE_Textbox);

// panel_TextComments.Controls.Add(img_Drag);


// this.PH_Master_Page.Controls.Add(panel_TextComments);

// drag_panel.DragHandleID = "img_Drag" + Convert.ToString(li_Count);
// drag_panel.TargetControlID = "panel_TextComments" + Convert.ToString(li_Count);

// this.PH_Master_Page.Controls.Add(mt);

// //drag_panel.ID = "DPE_TextComments" + Convert.ToString(li_Count);

// //this.PH_Master_Page.Controls.Add(drag_panel);
//}
//else
//{
// this.PH_Master_Page.Controls.Add(mt);
//}

Vivek.deshmukh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vivek.deshmukh on: 7/2/2011 [Member] Starter | Points: 25

Up
0
Down
Add in master page aspx page



<%@ Register TagPrefix="User_Control" TagName="Movable_Textbox" Src="~/Controls/Movable_Text.ascx" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ACT" %>

Vivek.deshmukh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response