Ralph Krausse wrote:WebControls such as Button offer a higher level abstraction than HTML> I know more html is needed to really produce this but enough is here
> for me to ask my question. So, this HTML code produce 2 buttons. One
> button is a HTML control and the other is ASP Web or Server Control.
> Why are there 2 ways to create buttons if they so the same thing? Do
> they do the same thing? In what senario would I use a HTML button
> rather than a Web control button. Does it matter? If not why 2
> different controls that do the same thing.
> <form id="Form1" method="post" runat="server">
> <INPUT style="Z-INDEX: 101; LEFT: 104px; POSITION: absolute; TOP:
> 40px" type="button" value="Button1" id="Button2" name="Button2"
> <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 104px; POSITION:
> absolute; TOP: 88px" runat="server" Text="Button2"></asp:Button>
controls. See for example the way you set each button's text. For the HTML
control, you use its HTML attributes like "value" (which isn't terribly
self-describing to developers not familiar with HTML), whereas the
WebControl uses a property called "Text". If you wanted to set the button's
color, you can simply set the Button.Color to an object of type Color. No
such luck with <input />, where you have to dig out your HTML/CSS reference
to set the style attribute to some CSS value.
There are also WebControls that are a combination of many HTML elements,
like the DataGrid, and do not have any counterparts as HTML controls.
Which to use? That's an architectural question. When you have a lot existing
HTML that you want to beef up with some server-side logic, HTML controls
will get you started quickly, because you can add runt="server" to your
existing pages and off you go. If you start from scratch, check which
controls fulfill your requirements best. Note that you can easily mix both
control families in your pages.