User control vs Server control

I'm trying to understand html and asp.net.

It seems (please do correct me if I'm wrong!) that the code I write on my aspx pages on my web project are not all html. Rather, they're a code which is run by some "ASP.Net" compiler when a user makes an html request from their url (So thanks to runat server the "compiler" understands non-html tags such as <asp). Then – the "compiler" uses this code to create an html page on the fly. For example – this converts a Button to an input.

Is this true? If so, then, what is a user control?

Answers


ASP.NET has server side controls (Such as buttons, hyperlinks, gridviews etc). These all generate server side events (Button1_OnClick) which can be handled by C#/VB.NET code.

<asp:Button ID="btnCopyText" runat="server" /> // Calls the server side btnCopyText code

public void btnCopyText_Click(object sender, EventArgs e) {

}  

HTML has it's own controls which are rendered by the client's browser (client side).

 <button onclick="copyText()">Copy Text</button> // Calls the copyText() function (Client Side)

The ASP.NET Button gets rendered at the server side and then gets passed down to the client as a standard HTML Button (Shown above).

A custom user control is an ASP.NET Server Side control that is created by the programmer, it may contain several ASP.NET Server Side Controls such as a GridView and a button). An example would be, when the button is clicked it reloads the data in the GridView. This provides a way for an ASP.NET developer to write one custom control and reuse it when needed rather than write boilerplate code (repeating the same code).

http://msdn.microsoft.com/en-us/library/y6wb1a0e.aspx


Yes it is true all asp.net control renders as html but runat server tell its a server control.

A user control is a kind of composite control that works much like an ASP.NET Web page—you can add existing Web server controls and markup to a user control, and define properties and methods for the control. You can then embed them in ASP.NET Web pages, where they act as a unit


asp.net is programming tool that helps you generate html code fast and easy, the final goal is the full html page with all the rest components that needs to show like scripts, images, ajax calls etc.

the user control, is like an object that render also html, but you can use it many times, in many different pages, or on the same page.

Eg a user control may render the image and the details of a product, then if you use it inside a repeater you can render all the products of your database with one only control, and a loop.

that the code I write on my aspx pages on my web project are not all html.

What you write on your aspx page is actually programming code that asp.net parse and render the final html page. Asp.net is allow you to have inside the code and html and other text, and you separate the part that must be parse from the rest text using the asp.net special tags and declarations.


Need Your Help

How to copy cell values from WorkSheet1 to WorkSheet, aka, how to create a masterlist in Excel using VBA?

excel vba cell rows

I am trying to create a master list of several excel data that I have. I have never worked with Excel + VBA programs/codes.

Symbol Motorola mc65 and datawedge

symbols motorola

i have an windows mobile application written in c# compact framework which use barcode scanner. In fact that i need to keep my app device independent i don't use constructor's api but i handle scan...