I got a master page with a content place holder (called: placeForButtons). In one of my forms a panel (called: uxButtonsPanel) is added as one of its controls . Later when the program is running (after it compiled what it had successfully) I try to add a button( called: uxInteractionButton0) to that panel.

the following error is shown:
Control 'ctl00_placeForButtons_uxInteractionButt… of type 'Button' must be placed inside a form tag with runat=server.

this is the code that gave the error:

Button elButton = new Button();
            elButton.Text = "button";
            elButton.ID += "uxInteractionButton0";
            elButton.Click += On_Click_Button;
            uxButtonsPanel.Controls.Add(elButton);

What I'm I missing to add the button?
If I'm missing the tag, how do I add it?

You aren't technically posting in the right place, that appears to be a asp.net question written in C#, there is an asp.net forum here at daniweb for that. you might get better help there.

the error states your code should have the <%runat="server"%> tag.

but it could also be that you didn't name your button with the "name" property, and also your click event code is incorrect. the correct syntax for adding a button click event in C# is button1.Click +=new EventHandler(button1_Click); but I cannot be sure, as I don't frequently use asp.net, my web server only supports classic asp. and I write C# forms applications.

best of luck.

Please use code tags when posting code on daniweb:

[code=c#] ...code here...

[/code]

Also please direct ASP.NET questions to the ASP.NET Forum

Post the contents for the master page and the content form for the master page. That is a rather odd error because the content place holder needs to be inside of a server tag .. so i'm not sure why the button wouldn't fall under that either unless your page declaration isn't runat="server" for the nested page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.