Page_Init vs OnInit

后端 未结 6 564
日久生厌
日久生厌 2020-12-08 07:40

Between handling the Page_Init event or overriding the OnInit method of a Page, which one is better to use? Thanks.

6条回答
  •  忘掉有多难
    2020-12-08 07:56

    OnInit is better because it is on class level initialization while page init can have redundant effect because you have to check if it is a postback or not.

提交回复
热议问题