tags:

views:

37

answers:

1

Hi, I get the following error when I try to add an ajax DragPanelExtender programatically.

The TargetControlID of '' is not valid. A control with ID 'ajaxPanel' could not be found.

Here's my code:-

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Panel ajaxPanel = new Panel();
        ajaxPanel.ID = "ajaxPanel";
        ajaxPanel.Height = 100;
        ajaxPanel.Width = 100;
        ajaxPanel.BorderColor = System.Drawing.Color.Brown;

        AjaxControlToolkit.DragPanelExtender panelExtender = new AjaxControlToolkit.DragPanelExtender();
        panelExtender.TargetControlID = ajaxPanel.UniqueID;
        Page.Form.Controls.Add(panelExtender);

    }
}

How do I fix this ?

Thanks.

A: 

The problem is there:

panelExtender.TargetControlID = ajaxPanel.UniqueID;

Instead of UniqueID use ID

EDITED: You have created

Panel ajaxPanel = new Panel();

but didn't append to page:

Page.Form.Controls.Add(ajaxPanel);
Dewfy
Hi, I still get the same error.
soontobeared
@soontobeared just append one more error
Dewfy
@soontobeared my pardon! Not ClinetID but ID
Dewfy

related questions