Catching unhandled exceptions in ASP.NET UserControls

前端 未结 7 1861
猫巷女王i
猫巷女王i 2021-01-06 00:58

I\'m dynamically loading user controls adding them to the Controls collection of the web form.

I\'d like to hide user controls if they cause a unhandled exception wh

7条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-06 01:43

    I am not sure I understand your response.. How are you loading your controls and adding them to your controls collection?

    That was the whole point of the bit added in the "Update" section.. You have the flexibility to use the SafeLoader wherever you please.

    I am not sure why you feel you don't have access/control over the Html? The goal of the SafeLoader is that you dont care what the html is, you simply try and "output" the control (within the "bubble") and determine if it loads OK in its current state.

    If it does (i.e. the html is returned) then you can do what you like with it, output the html, add the control to the controls collection, whatever!

    If not, then again, you can do what you like, render an error message, throw a custom exception.. The choice is yours!

    I hope this helps clarify things for you, if not, then please shout :)

提交回复
热议问题