How do I set an ASP.NET Label text from code behind on page load?

前端 未结 7 1699
终归单人心
终归单人心 2020-12-03 07:39

I can\'t seem to find an answer out there for this. Here\'s the scenario: I have an ASP.NET project using C#. I\'m loading data (Username, email, etc...) from a sqlite datab

相关标签:
7条回答
  • 2020-12-03 08:11

    If you are just placing the code on the page, usually the code behind will get an auto generated field you to use like @Oded has shown.

    In other cases, you can always use this code:

    Label myLabel = this.FindControl("myLabel") as Label; // this is your Page class
    
    if(myLabel != null)
       myLabel.Text = "SomeText";
    
    0 讨论(0)
提交回复
热议问题