SearchBox.cs and "best practices"?

Topics: ASP.NET 2.0, Controls, Themes
Aug 3, 2007 at 11:32 PM
Edited Aug 3, 2007 at 11:46 PM
Hi,

I have a background in desktop development, but I'm just learning ASP.NET, CSS and HTML.

While customizing my own theme I came across the code for the blog "search box" that lives in the sidebar. I assume embedding HTML in the C# code is not considered "best practices"? It makes it harder to modify. Actually, I just realized that most of the *.cs files in App_Code/Controls use the same technique. I'm guessing that "best practices" would lean more towards putting things in *.ascx files like PostView.ascx does?

Why would I want to modify it? For my personal theme design my highest priorities are a liquid-layout and scalable text. In other words I want the design to adapt to and look good for a wide range of browser window widths and text sizes. An example is news.google.com. Although the "search box" looks OK with a fixed-text-size design, it doesn't do as well when you let the text size vary.

BTW, I appreciate all the work you guys have done.

Thanks,
Alex
Coordinator
Aug 6, 2007 at 10:22 AM
There is nothing wrong in outputting HTML in a server control like the ones in App_Code/Controls/. The problem is when you apply style to the HTML instead of letting a stylesheet handle it. If there is style in the search box, I will correct it.