Reputation: 85
I am trying out with asp.net . One thing i was surprise is that in our design code we don't used general <html>
,<body>
etc. but we used <asp:content>
, <asp:button>
etc. well i tried to find it out why but ended upon the abstract msdn pages . So please help me on this one
Upvotes: 2
Views: 250
Reputation: 12341
Tags with <asp:...
tag prefix means they are "server side controls", which means:
they are accessible to your program on the server side (events, parameters, etc.) and by client side script (e.g. JavaScript)
they will be "rendered" (output when running/"translated to") as standard HTML tags when you actually run your web site
As an example, while you are building your web page/s the tag <asp:textbox runat="server" id=foo...
will output as <input type="text" id="foo
when you run the ASP.net application in a browser.
You can create a simple web page, run it in a browser, then VIEW SOURCE
to see this "translation" at work.
So while you are developing/designing your web application, ASP.Net will provide you with what they call "controls" (e.g. button controls, label controls, etc.). They will all be translated into standard HTML tags/elements at runtime.
The above relates to ASP.Net technology called "Web Forms".
You can start with it - its a bit easier to program against. When you get more advanced and/or prefer to do more "bare metal" standard HTTP POST/GET, then you can look into ASP.Net MVC/Razor - this ASP.Net architecture will let you use standard HTML and pretty much control everything (which also means you need to know how to control 'everything').
Upvotes: 2
Reputation: 56429
There's nothing wrong with using HTML tags in ASP.NET pages, as long as you use runat="server"
on them of course. I like to use a bit of both, dependent upon what it is. I suppose a benefit of using HTML tags means that you become more comfortable with the HTML and do not depend on the ASP.NET syntax.
On the other hand, in some cases, it would be an incredibly laborious task to actually write ALL of the HTML in order to replicate a control. Something like a complex DataGrid
with all the events would be an absolute nightmare to write the pure HTML/JavaScript for. Using the ASP.NET control & syntax makes it much quicker and cleaner in that scenario.
Upvotes: 0