ASP.NET How to dynamically add attributes to BODY tag of MasterPage

Line ‘Master.Master.Master.FindControl’ will depend on how many nested MasterPages you have and from where you try accessing specific control

Private Sub SetMasterBodyClass()    Dim bodyClass As HtmlGenericControl = DirectCast(Master.Master.Master.FindControl("bodyClass"), HtmlGenericControl)    If Not bodyClass Is Nothing Then        If CurrentLanguageCode = "french" Then            bodyClass.Attributes.Add("class", "french")        End If    End IfEnd Sub


Leave a Reply

Your email address will not be published. Required fields are marked *