Solved

Write vb.net code in page.aspx, or page.aspx.vb ?

Posted on 2011-09-13
4
392 Views
Last Modified: 2013-11-05
Hello,
I would like from someone to explain is it better to write vb.net, or C# code inside of page.aspx, or behind page.aspx.vb(c#)?

My thoughts:
1.'m used to write vb.net, c# codes in page.aspx.vb(c#), and also sense is telling me, if Page.aspx has less lines, then pages are more quicly loaded ?!
2.But, in other side, if vb.net, c# codes are written inside of page.aspx, then codes are faster executed?!

False/True ?

Thank you in advance for help to anyone!
0
Comment
Question by:dejandejanovic
4 Comments
 
LVL 35

Assisted Solution

by:Miguel Oz
Miguel Oz earned 200 total points
ID: 36532709
1. false, asp.net will join both aspx and code-behind(C#, vb) as one resource.
2. False, location is not important.
aspx and code-behind separation is done to allow developers to have a clear separation between User interface and code.

How you design your code  and our page contents will influence the performance.
0
 
LVL 7

Assisted Solution

by:mr_nadger
mr_nadger earned 100 total points
ID: 36535417
as an extension to previous poster's comment, maintaining the seperation between the page design and the code will help keep your code cleaner and better organised, helping anyone who has to support your page.
It also makes it a little easier to copy code into other projects ;)
0
 
LVL 9

Accepted Solution

by:
sachinpatil10d earned 200 total points
ID: 36535440
Coding c#/Vb .net using the code behind is always good

Code-behind refers to code for your ASP.NET page that is contained within a separate class file. This allows a clean separation of your HTML from your presentation logic

code-behind can be deployed in dll which works faster.

mycodebehind.aspx
mycodebehind.cs

Syntax to compile codebehind

csc.exe /out:mycodebehind.dll /t:library mycodebehind.cs

code-behind page inherits from the Page class

Inheriting from the Page class gives the code-behind page access to the ASP.NET intrinsic objects, such as Request and Response

you can reference the code-behind class by using an SRC tag
In this case, ASP.NET compiles the code-behind page on the fly.

When you use Microsoft Visual Studio .NET to create ASP.NET Web Forms, code-behind pages are the default method. In addition, Visual Studio .NET automatically performs precompilation for you when you build your solution. Note that code-behind pages that are created in Visual Studio .NET include a special page attribute, Codebehind, which Visual Studio .NET uses.
0
 

Author Closing Comment

by:dejandejanovic
ID: 36536302
Cool. Thanks for explanation.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now