How to create div dynamically in asp.net

I have a text box and a submit button.

When I click the submit button, the div should be added dynamically on my aspx page.

Also, the information available in the text box is also displayed on the default page.

Usage: Without using a database, I need to display the user's suggestion on my page ...

+4
source share
1 answer

You have 2 options:

  • Dynamically, you can add an asp.net panel that generates a div tag.

    // Create dynamic controls here.
    // Use "using System.Web.UI.WebControls;"
    Panel panel1 = new panel ();
    panel1.ID = "MyPanel";
    Form1.Controls.Add (panel1);

  • Create a div using jQuery

Select the parent element with $("#id") , $("&lt;element&gt;") or $(".class") , and then $(theElement).append("<div>Your content</div>");

+12
source

Source: https://habr.com/ru/post/1309550/


All Articles