How to add user control on run time in ASP.NET?

后端 未结 4 1736
情话喂你
情话喂你 2021-01-18 23:55

How do I add a user control on page load dynamically in ASP.NET?

I have a div with ID=\"contentData\" and few controls

  • one.ascx
  • t
4条回答
  •  遇见更好的自我
    2021-01-19 00:31

    Use the Page's LoadControl method to do this programmatically:

    http://msdn.microsoft.com/en-us/library/t9ecy7tf.aspx

    Also, if your intention is to add it to the div, make sure you make that div a server control by adding runat="server" in the markup

提交回复
热议问题