Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2014, 11:13 PM
Authorized User
 
Join Date: Jun 2014
Posts: 16
Thanks: 7
Thanked 0 Times in 0 Posts
Default Chapter 2: CodeBehind and CodeInline

Hello to all fellow programmer,

CodeBehind Files

1. The file are created and named after the master.aspx file with additional extension *.vb or *.cs
and are store in the same folder as the master file.

Can we place the file or our customised CodeBehind files to a different folder from the master file
and provide the linkage to all this files as and when needed using <a href), is this a good idea?

CodeInline Files

1. The file are embedded in the master.aspx and its content are stored under the <script> tag.

Am I saying it right, or the content can also be stored in other HTML elements apart from the script?

Thank you very much.

Cheers
Mohamad

Last edited by mohamad; June 19th, 2014 at 11:17 PM..
 
Old June 20th, 2014, 03:44 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

>> and provide the linkage to all this files as and when needed using <a href), is this a good idea?

Nope, it's not, and it's not how it works. Neither the Master File nor its code behind ever make it to the browser. They serve to define the presentation and behavior of other pages (Content Pages) only and are never used at the client. As such you cannot link to them.

>> The file are embedded in the master.aspx and its content are stored under the <script> tag.

Well, the *code* should be in a Script element. All other content can be in other places in the page like inside a <head> or <body> element.

>> Am I saying it right, or the content can also be stored in other HTML elements apart from the script?

Other content can, but the server side code cannot.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
mohamad (June 20th, 2014)
 
Old June 21st, 2014, 11:20 PM
Authorized User
 
Join Date: Jun 2014
Posts: 16
Thanks: 7
Thanked 0 Times in 0 Posts
Default

Thanks Imar,

1. Can we have many code behind files for the master file?


a. And if possible how's the naming convention for the additional files for the
master to take precedence?

Cheers,
Mohamad
 
Old June 22nd, 2014, 02:57 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

A master page only has a single code behind file. .net supports the concept of partial classes that allows you to split complex classes into multiple files. However you typically don't have a lot of code behind the master page so I don't think that partial classes are a good fit in this scenario.

cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
mohamad (June 22nd, 2014)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Codebehind for conditional visibility Nostromo77 ASP.NET 2.0 Basics 4 September 21st, 2008 08:00 PM
Codebehind not working angshujit ASP.NET 1.0 and 1.1 Basics 1 September 21st, 2007 07:32 AM
JSP Codebehind buddhudev Pro JSP 0 October 1st, 2005 02:33 PM
Ch15 CodeBehind mahir BOOK: Beginning ASP.NET 1.0 2 May 8th, 2004 01:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.