Implementation of IsPostBack in page load

后端 未结 8 1047
你的背包
你的背包 2020-12-06 00:07

The more I use ASP.NET, the more if (!IsPostBack) {} seems pointless...

First example:

For example, I just Googled an issue, they said use this

8条回答
  •  天涯浪人
    2020-12-06 01:02

    What can happen if you cause a postback is you can change the state of your controls, without meaning to. For example in using a gridview, if you postback during edit mode, you will no longer have access to your edit-ed fields.

    Often you need to preserve the information from disapearing on a page when you hit the server, this is the point of

    if(!Page.IsPostBack)
    

提交回复
热议问题