Is it good or bad to write everything in C # rather than using web controls?

I am confused with the choice between several ways to get the result in ASP.NET.

For example, managing a web form SqlDataSource, you retrieve data from a database and display results in other controls, such as DataGridView, BulletedListetc. However, all these things can be written in C #, creating a line that will hold your HTML codes with the extracted data, then you paste your HTML code in divwith innerHTML. Who cares?

Example:

[ <div id='block1' runnat='server'></div]  

and in CodeBehind

[ block1.innerHTML = myString;]

After writing C # SqlConnect, Loops, Datatable code, you put the value of your HTML string in myString.

Why not implement everything with C #?

+3
source share
3

, . , , , " ". , , ASP.NET .

- , .

. , . , :

  • ?
  • ( ) ? - , .
  • ?
  • ? - , .
+5

# , , html- - , html .

MVC ; , , # html :

<div id="@obj.Id">
  <ul>
    @foreach(var item in obj.Items) {
      <li>@item.Name</li>
    }
  </ul>
</div>

:

  • , ,
  • , , IDE , , -
+3

.

, , ? , , , , .

,

  • HTML (, Building)
  • / CSS, (, Paint)
  • C# (or specific code for a specific) is for logic (e.g. convenience or wiring).
+2
source

Source: https://habr.com/ru/post/1791148/


All Articles