开发者

Are there any difference between aspx and code behind when assigning text values asp.net 4.0 c#

开发者 https://www.devze.com 2023-04-07 17:37 出处:网络
This is code behind assigningaspx.cs if (srLang == \"tr\") { lblUn开发者_开发问答WantedPrivateMessages.Text = \"Özel Mesaj Almak İstemediğiniz Oyuncular\";

This is code behind assigning aspx.cs

      if (srLang == "tr")
    {
        lblUn开发者_开发问答WantedPrivateMessages.Text = "Özel Mesaj Almak İstemediğiniz Oyuncular";
        lblPmBlockUserNameTitle.Text = "Oyuncu Adı:";
    }
    else
    {
        lblUnWantedPrivateMessages.Text = "Players That You Don't Want To Receive PM";
        lblPmBlockUserNameTitle.Text = "Player Name:";
    }

and this is aspx assigning

    <%    
    if (srLang == "tr")
    {
        lblUnWantedPrivateMessages.Text = "Özel Mesaj Almak İstemediğiniz Oyuncular";
        lblPmBlockUserNameTitle.Text = "Oyuncu Adı:";
    }
    else
    {
        lblUnWantedPrivateMessages.Text = "Players That You Don't Want To Receive PM";
        lblPmBlockUserNameTitle.Text = "Player Name:";
    }
     %>

Are there any performance difference between these 2 ?


Both will compile into equivalent code, and there will be no performance difference.

Placing significant code in the code behind file allows for a separation of responsibilities (display markup in the aspx file, logic in the code behind file) and leads to code that is easier to maintain.

0

精彩评论

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