Using FindControl() to find control

前端 未结 5 2199
广开言路
广开言路 2021-01-04 06:17

I have a Literal control that I am trying to locate so I can insert text into it. I have a Master page that contains several content placeholders.



        
5条回答
  •  长情又很酷
    2021-01-04 07:18

    From within the masterpage:

    var literal = (Literal)FindControl("MainLinks").FindControl("litNavLinks");
    literal.Text = sb.ToString();
    

    From within the view:

    litNavLinks.Text = sb.ToString();
    

提交回复
热议问题