开发者

asp.net web forms constructor?

开发者 https://www.devze.com 2023-03-27 09:17 出处:网络
I want to load a dictionary w开发者_如何学运维ith some data and use it in the button event handler of a web form. Where is the appropriate place to put this code? There is a Page_Load method, but I do

I want to load a dictionary w开发者_如何学运维ith some data and use it in the button event handler of a web form. Where is the appropriate place to put this code? There is a Page_Load method, but I don't want it to run every time the page loads.


in a Page Load event handler, call the method only once when the page first loads.

protected void Page_Load(object sender, EventArgs e)
{
    if(!IsPostBack)
    { 
        // your code to load dictionary here, or a method call.
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消