When to use HtmlControls vs WebControls

I like HtmlControls because HTML magic doesn't happen ... the asp source is similar to what the client sees.

I can not argue with the utility GridView, Repeater, CheckBoxLists, etc., so I use them when I need this functionality.

In addition, it is strange to have code that mixes and maps:

<asp:Button id='btnOK' runat='server' Text='OK' />
<input id='btnCancel' runat='server' type='button' value='Cancel' />

(The above case, if you want to bind the server side event listener to OK, but Cancel just runs javascript that hides the current div)

Is there any definitive leadership style? Should HtmlControls be Avoided?

+5
source share
4 answers

, HTML , , , . , , ​​ .

System.Web.UI.HtmlControls, :

<input id='btnCancel' runat='server' type='button' value='Cancel' />

, . :

<asp:Button id='btnCancel' runat='server' Text='Cancel' />

. WebControl. WebControls , HTML . DataGrid - , .

WebControls, HtmlControls, ASP.NET v2.0 ControlAdapters, , , WebControls, , .

, , - WML .

+5

, . , , HTML, , .

, HTML, runat = "server" .

+3

... html, .

<input id='btnCancel' type='button' value='Cancel' />

.

+1

runat = "server", HTML . , HTML ASP.NET.

0

All Articles