Implementation of IsPostBack in page load

后端 未结 8 1024
你的背包
你的背包 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:04

    When there is no need to repeat the operation other than the first time.

    use it with expensive operations (such as getting data from a database or populating ListItems) that must be performed only the first time the page or control is loaded. If the page is posted to the server and then reloaded, there is no need to repeat the operation. By testing the value of IsPostBack, you can skip the expensive operation,

提交回复
热议问题