User control and server management

I am trying to understand html and asp.net .

It seems (please correct me if I am wrong!) That the code that I write on my aspx pages in my web project is not all html. Rather, it is the code that the ASP.Net compiler runs when the user makes an html request from his URL (therefore, thanks to the runat server โ€œcompilerโ€ understands tags other than html, such as <asp ), then the โ€œcompiler "uses this code to create an html page on the fly. For example, this converts a Button to input .

It's true? If so, what is a user control?

+4
source share
3 answers

ASP.NET has server-side controls (such as buttons, hyperlinks, gridviews, etc.). All of them generate server-side events (Button1_OnClick) that 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 its own controls that are displayed by the client browser (client side).

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

The ASP.NET button receives server-side rendering and is then passed to the client as a standard HTML button (shown above).

A user-defined user control is an ASP.NET Server Side control created by a programmer; it can contain several ASP.NET Server Side controls, such as a GridView and a button). An example would be when a button is pressed, it reloads the data in the GridView. This enables the ASP.NET developer to write one custom control and reuse it when necessary, rather than writing boilerplate code (repeating the same code).

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

+4
source

Yes, itโ€™s true that all asp.net controls are displayed as html, but the runat server reports this to the server control.

A user control is a kind of composite control that is very similar to 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

+2
source

asp.net is a programming tool that helps you generate html code quickly and easily, the ultimate goal is a full html page with all other components that should be displayed as scripts, images, ajax calls, etc.

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

For example, a user control can display an image and product details, and then, if you use it inside a repeater, you can display all the products in your database with just one control and a loop.

that the code that I write on my aspx pages in my web project is not all HTML.

What you write on your aspx page is actually programming code that parses asp.net and displays the last html page. Asp.net allows you to have both html and other text inside the code, and you separate the part that should be parsed from the rest of the text using special tags and declarations from asp.net.

+1
source

All Articles