Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server Control or HTML control

Tags:

asp.net

i want to know is there any difference between server controls and HTML controls in speed? for example you want to create a log in page that have two textbox and a button for submitting data,you can do this with both server controls and HTML controls(client_side controls(input) ),do you prefer to use server controls or HTML controls and which one is more efficiently? which one is faster?

like image 439
Rasoul Avatar asked Apr 08 '26 04:04

Rasoul


2 Answers

You always want to validate on the serverside, trusting anything from the client is a big mistake

like image 176
Evan Larsen Avatar answered Apr 09 '26 23:04

Evan Larsen


Server Controls must be executed on the server and a Render method is called to generate the HTML. Therefore they cost a little bit of performance on the server. Depending on the control, they emit data in the ViewState as well, which costs a little bit of additional bandwidth (or very much depending on the control).

It depends on the type of control you want to use. As soon as there is any serverside processing involved (read a textbox, handle a button etc.), I always prefer the asp.net server controls, because they provide much more functionality. But if the control is just sent to the client (such as images, tables, divs etc.) I use HTML controls.

I think the server side processing doesn't take much, it takes a lot longer to get data from a database. Of course it depends on the number of users as well, whether you have to optimize or not. But I would rather use OutputCache instead of not using asp.net server controls.

Hope this helps.

like image 27
slfan Avatar answered Apr 10 '26 01:04

slfan