How to avoid Page_Load() on button click?

后端 未结 6 1833
鱼传尺愫
鱼传尺愫 2021-01-18 03:01

I have two buttons, preview and Save. With help of preview button user can view the data based on the format and then can save.

But when preview is clicked, one text

6条回答
  •  孤独总比滥情好
    2021-01-18 03:40

    I had the same problem and the solution above of "CausesValidation="False"" and even adding "UseSubmitBehavior="False"" DID NOT work - it still called "Page_Load" method.

    What worked for me was adding the following line up front in Page_Load method.

    if (IsPostBack) return; 
    

    I am mentioning this if it helps someone (I meant to comment above but StackOverflow did not allow me to comment because I am a new user - hence a new reply).

提交回复
热议问题