.Net Dynamicaly Create and Remove a Control / Object, such as a button. Web

    private void CreateControls()
        // Create a New Button
        Button myButton = new Button();
        // Give the Button Some Properties
        myButton.Text = "A Dynamicaly Created Button";
        // Add Button to PlaceHolder
        // ** NOTE: The Planel must Exist in your design view

    private void RemoveButton()
        // Search for the button in the Page Controls Collection
        Button foundButton = (Button)Page.FindControl("myButton");

        // Remove the Button
        if (foundButton != null)


Popular posts from this blog

Umbraco Razor Sort Nodes Ascending or Descending

Umbraco Razor get Querystring

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco