Hi, friends
I want to know that what's the difference between Inline Code and Code Behind? Which one is best please explain in brief?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
MuthuMari MPosted Apr 5, 2012, 12:58 AM
There are a few differences in the processing of code-behind and single-file(Inline) pages.
blocks in the same .aspx file that contains the HTML and controls.Pageclass.Pls refer this url for more details,
http://www.codeproject.com/Articles/8178/Inline-Single-File-vs-CodeBehind
If this post is useful then mark it as "Accepted Answer"
SenthilkumarPosted Apr 5, 2012, 12:35 AM
The ASP.Net provides the web page can be written in two ways.
1) Inline code
2) Code behind.
Inline:
The inline is design and design will be mixed in the .aspx page. The events and methods can be written part of the .aspx page. The inline can be selected while creating the web page, it asks the option "Separate the code File". When it is unchecked it will not create the .aspx.cs file.
The developer can write the code file in the script tag. When you write the code in .aspx page, it does not mean the written code will be visible to the users in the client browser like javascript.
Code Behind:
The code behind is code will be separated from the design page. It will create the .cs or .vb file for write the properties, events and methods in the class. It will be referred to the code file in the page directive.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
Best:
The code behind file is best. because there are some reasons.
1) Logic is separated from the design, so its good readability and easy to understand
2) The designers can work on the .aspx page and the developers can focus on the function in the server side.
3) It will avoid to make the confuse of javascript section and code section
For more Info:
http://www.codeproject.com/Articles/8178/Inline-Single-File-vs-CodeBehind