ASP.Net Programming tips for absolute beginners
1) Always place the database connection details in web.config or any other external configuration file. If you add the configuration details in web.config, you have to place it under configuration in appsettings. I am giving a sample implementation fo the same below.<configuration>
<appsettings>
<add key="connIntranet" value="Persist Security Info=False;Data Source=(local);Initial Catalog=mydatabase;User ID=;Password=;Trusted_Connection=Yes"/>
</appsettings>
</configuration>
To access this in your code in your .aspx page, you have to use ConfigurationSettings.AppSettings("connIntranet")
By doing so, you have the advantage, when you change the project from your development environment to your real deployment environment, you just have to change the details in the web.config file and not in all your program pages.
From your .vb file to access the connection details, you use
System.Configuration.ConfigurationSettings.AppSettings("connIntranet")
Eg. Dim MyConnection as SqlConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("connIntranet"))
2) Use stylesheets (.css) files to control the appearance or layout of your files. Background colors, font face etc details can be placed in the stylesheet page. The advantage of using a stylesheet is same as above. If you wanted to change the background color of all your pages, all you have to do is just make changes in the stylesheet and not in all pages of your site.
3) ASP.NET 2.0 has introduced a concept of Master Pages. Using master pages is similar to using templates in Dreamweaver (I will be posting many dreamweaver tutorials in this section very soon. So watch out for this space). The entire layout of the pages can be changed by making changes to this Master page. If you are not using ASP.Net 2.0 you can try using user controls for your pages. User controls for header, footer and navigation. and Include it in all pages. You make changes to the user controls and it is reflected in all the pages. You can use simple user controls for the header. Just copy the header code (banner, images, company logo etc) and place it in a separate file and name it as header.ascx and include it in your main page (More tutorials to come).





