c# - error using FindControl on div id

前端 未结 4 1215
小蘑菇
小蘑菇 2021-02-15 14:32

I have an ASP.NET site that I am trying to access div elements by their ID from the C# code behind file. Essentially I want to see if a div element exists, and if so, alter its

4条回答
  •  余生分开走
    2021-02-15 15:19

    If you add runat=server please add it at last of the div:

    This will work

    However, this will not

    By doing that, you can modify any property from codebehind as:

    divBtn.Style["display"] = "none";
    

    This works even with masterpages. The div is not included in a masterpage.

提交回复
热议问题