Dynamically Load a user control (ascx) in a asp.net website

后端 未结 6 1313
情话喂你
情话喂你 2020-12-09 06:41

I am trying to dynamically load a user control in an asp.web site. However due to how asp.net websites projects are setup (I think), I am not able to access reach the type d

6条回答
  •  我在风中等你
    2020-12-09 06:45

    Casting the user control this way may create many problems .my approach is to create a class (say control Class) put all the properties and method you need for casting in it and inherit this class from System.Web.UI.UserControl .Then in your user cotrol code file instead of System.Web.UI.UserControl user this control class .

    now when ever you need casting, cast with this class only . it will be light casting as well.

提交回复
热议问题