asp.net - When to use HtmlControls vs WebControls -


i htmlcontrols because there no html magic going on... asp source looks similar client sees.

i can't argue utility of gridview, repeater, checkboxlists, etc, use them when need functionality.

also, looks weird have code mixes , matches:

<asp:button id='btnok' runat='server' text='ok' /> <input id='btncancel' runat='server' type='button' value='cancel' /> 

(the above case in event wanted bind server-side event listener ok cancel runs javascript hides current div)

is there definitive style guide out there? should htmlcontrols avoided?

it might useful think of html controls option when want more control on mark ends getting emitted page. more control in sense want every browser see same markup.

if create system.web.ui.htmlcontrols like:

<input id='btncancel' runat='server' type='button' value='cancel' /> 

then know kind of code going emitted. though of time:

<asp:button id='btncancel' runat='server' text='cancel' /> 

will end being same markup. same markup not emitted webcontrols. many webcontrols have built in adaptive rendering render different html based on browser user agent. example datagrid quite different in mobile browser in desktop browser.

using webcontrols opposed htmlcontrols lets take advantage of asp.net v2.0 controladapters believe works webcontrols, allow programatic config driven control on markup gets emitted.

this might seem more valuable when consider mobile browsers or webtvs going want wml or different sets of markups.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -