Thursday, March 29, 2012

Separate vb page?

Question, in two parts, I have separated my vb code from the asp page. But, I have noticed on many code samples this is not 'normally' being done. I have also noticed that it is easier to reference controls if you write your scripts on an asp page. If you separate your vb code from an asp page what is the best way to reference your controls and their properties? Also, What is considered 'best practice'? Should you separate them or not?

Thanks in advanceMarvin

As far as using code behind, I don't think that it is a best practice but a personal choice. I personally like the code behind because it keeps all my code in one place and easier for me to referrance. When I need to add an even or sub, I just double click on either the object or page depending on what I want to do.

OK... what you want to be doing is usingCodeBehind. You can select this as an option when you create your page.

Whether you use codebehind or have it on the page will makeno difference with regards to accessing your controls and their properties.

Many samples don't use code behind because it ismuch easier to post a sample that novice users can just paste into a page when you include the server-side script in the page.


Thank you both for your replies.

James, forgive me I am still new to all of this asp.net. When you say 'codebehind' do you mean... separating the vb from the ASP page? I am assuming this is correct. right?


Codebehind separates the markup (asp to you) and the source code (vb/c#) but maintains a link between them.

See this...http://support.microsoft.com/kb/303247

0 comments:

Post a Comment