If your div has runat="server" then you directly use this:
divId.Attributes["class"] = "classname";
Tech Controls is a site aimed at web developers and designers offering tutorials and articles on technologies, skills and techniques to improve how you design and build websites and provide the solution of problems. We cover ASP.NET, MVC 3, C#.NET, HTML, CSS, JavaScript, SQLServer 2005/2008/2012 and Interview Questions and Answers on .Net.