2

I am creating a new Panel..

 public class LicensingPanel : Panel
{
     private LinkButton licenseButton;
    ...
}

I am then in the code adding my controls to the Controls property, one of which is a LinkButton.

What I want to be able to do on my Page code behind is the following..

protected override void CreateChildControls()
{
    Controls.Add(new LicensingPanel(this));

    base.CreateChildControls();
}

But I am getting this error message:

Control 'ctl03' of type 'LinkButton' must be placed inside a form tag with runat=server. at System.Web.UI.Page.VerifyRenderingInServerForm(Control control)

The page is a SharePoint page with a master page, it has a Form tag with runat=server.

Any help is greatly received!

Best Regards,

Phill

4 Answers 4

4

Any page with a MasterPage, whether it is in SharePoint or not, is a Content Page. These pages only support content contained in Content controls. Attempting to add an HTML tag or ASP.NET control directly to the page is not supported.

Sign up to request clarification or add additional context in comments.

Comments

0

Where on the page is the control of your type LicensingPanel ? This control needs to be inside the form tag.

Comments

0

I think you should tell us a little bit more about what you want to archive with your code. Where are you trying to add your control?

Comments

0

I think that you need to complete some steps before you can use a certain control inside a MOSS 2007 environment:

  1. You must register your custom controls DLL as safe.
  2. You must register your custom control in the master page in order for the server to recognize the tag.

FOR DLL: <%@ Register TagPrefix="customcontrolname" Namespace="MyCustomControl" Assembly="MyCustomControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=123456789abcdefg" %>

FOR ASCX: <%@ Register Src="~/Controls/MyCustomControl.ascx" TagName="MyCustomControl" TagPrefix="customcontrolname" %>

1 Comment

Hi Emilio, Thanks, I am aware of the requirements for SP and controls. I thought I was abled to dynamically add my own controls which according to Rob below can't be done. Regards Phill

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.