Monday, May 9, 2011

Redirection to a new Aspx Page

This is a quick blog about how you can redirect to another page.

Response.Redirect("~/Path/To/Your/File");

This code is very simple you just call the 'Response' scope and the method "Redirect" and input the path and the file you want to redirect to as a string. And when the code is hit in your site it will redirect to your inputed content page.

Wednesday, April 13, 2011

SQL-IF and CASE

This time around am going to take a look into the 'if' and 'case' used in SQL... as you can see in the code given below you have a very good feature from SQL. Making decisions inside a query can come in very handy as show below in the given 'if' statements included in this query.

DECLARE @num int
SET @num = 4

DECLARE @salesPersonId int

if @num = 3
BEGIN
 set @salesPersonId = 
 (
  SELECT top 1 SalesPersonID
  FROM Sales.SalesPerson
 )
 SELECT 'The number is 3' [Output]
END
ELSE IF @num = 4
BEGIN
 set @salesPersonId = 4
 SELECT 'The number is 4' [Output]
END
ELSE
BEGIN
 set @salesPersonId = -1
 SELECT 'The number is not valid' [Output]
END


IF @salesPersonId = -1
BEGIN
 SELECT 'No Sales Person selected' SalesPersonId
END
ELSE
BEGIN
 SELECT @salesPersonId SalesPersonId
END

Below this paragraph is a code snippet with a 'case' used to set the 'EmailPromotion' to a more user friendly look, it is actually given as an 'int', by taking in the EmailPromotion and setting it to a string that better ids the kind of promotion that the person is asking for.

SELECT FirstName, LastName,
(
 CASE EmailPromotion
  WHEN 1 THEN 'EmailPromo'
  WHEN 2 THEN 'TextPromo'
  ELSE 'NadaPromo'
 END
) Promo
FROM Person.Contact c

More to Come, CA.

Monday, April 11, 2011

The "UNION" of SQL

"The UNION operator is used to combine the result-set of two or more SELECT statements." Given to us by: http://www.w3schools.com/sql/sql_union.asp.

What this does it take the first "SELECT" statement, and tack on the second "SELECT" statement to the end of it.

SELECT SalesPersonID
FROM Sales.SalesPerson
UNION
SELECT ContactID
FROM HumanResources.Employee

Taking a look at this code snippet we take all of the "SalesPersonID" from "Sales.SalesPerson" and all of the "ContactID" from "HumanResources.Employee" and combine them together, even if there are duplicate records.

There is a "UNION ALL" that can be used in the place of just plain "UNION" that will actually give all the records as single records, giving no duplicated records.

Wednesday, April 6, 2011

Some Awesome Sub-query Practice

Lets take a look at some SQL again, this is three problems that need to be figured out I will be using the database called AdventureWorks...

The first problem to figure out is this..."Select first name, lastname, and email of employees who are sales people"
SELECT c.FirstName, c.LastName, c.EmailAddress
FROM Person.Contact c
WHERE c.contactID IN
 (
 SELECT e.ContactID
 FROM HumanResources.Employee e
 WHERE e.EmployeeID IN
  (
   SELECT SalesPersonID
   FROM Sales.SalesPerson
  )
 ) 
First I actually found the "SalesPersonID" of all the records in the "Sales.SalesPerson" table, this gives me all the IDs in a single table that I can then use to get all the "SalesPersonID" records that are also the same as the "EmployeeID" in the "HumanResources.Employee" table. From the combination of both of these two tables, the "Sales.SalePerson" and "HumanResources.Employee", I get the "ContactID" from the "HumanResources.Employee" table, after it has been sorted through. That allows me to use the "Employee" table "ContactID" and get all "ContactID" records that are also in the "Person.Contact" table "ContactID" records, getting all the records that fall into this criteria I am able to get the "FirstName", "LastName", and "EmailAddress" of all records sorted out by the sub-queries.

The next problem is..."Get emails of all sales people who have made a sale greater than $150k"
SELECT sp.SalesPersonID, c.EmailAddress
FROM Person.Contact c, Sales.SalesPerson sp 
INNER JOIN HumanResources.Employee e
 ON sp.SalesPersonID = e.EmployeeID
WHERE sp.SalesPersonID IN
 (
  SELECT soh.SalesPersonID
  FROM Sales.SalesOrderHeader soh
  WHERE soh.TotalDue > 150000
 )
AND
 c.ContactID = e.ContactID
This query gets all the information from the "Contact" table, to get the "EmailAddress" of the employees. And by using an "INNER JOIN" to "join" the "SalesPerson" and the "Employee" tables to get all the "Employee" records that are only in the "SalesPerson" table. By using the "SalersPersonID" we are able then use a nested select statement to get only the "SalesPersonID" where that record has a "TotalDue" greater than 150,000. And to finally get the "EmailAddress" we only grab the records where the "Contact" "ContactID" is equal to the "Employee" "ContactID".

Another problem to figure out was..."Query all the products that have not sold and figure out the markup by subtracting the standardcost from the listprice. Order the query by markup descending."
SELECT p.Name, p.ProductNumber, (p.ListPrice - p.StandardCost) Markup
FROM Production.Product p
WHERE p.ProductID NOT IN
 (
  SELECT sod.ProductID
  FROM Sales.SalesOrderDetail sod
 )
ORDER BY Markup DESC
This query starts by taking the "Name", "ProductNumber", "ListPrice", and "StandardCost" of the records in the "Product" table. Since I wanted to get an answer that would list the "Marked up" price of all the product not sold, I pulled from all the products and then used a sub-query to get all product in the "SalesOrderDetail", this actually gives me a list of all the product sold. so using a "NOT IN" "WHERE" I am able to all the products "NOT SOLD". Nice huh...

More To Come, CA.

Wednesday, March 30, 2011

Example of Sub-Queries

Here is a sub query that has a sub-query in the "SELECT" clause of the main query, and another in the "FROM" Clause

use AdventureWorks

DECLARE @range datetime
set @range = '20030101'

SELECT AVG(T.Total) as Average, 
 (
  SELECT COUNT(*)
  FROM Sales.SalesOrderHeader
  WHERE OrderDate between @range and DATEADD(year,1,@range)
 ) as ORDERCOUNT
FROM ( 
  SELECT SUM(sh.TotalDue) Total, sh.CustomerID
  FROM Sales.SalesOrderHeader sh
  WHERE OrderDate between @range and DATEADD(year,1,@range)
  GROUP BY CustomerID
 ) AS t
Lets take a look at what this query actually does. Starting, I "DECLARE" a "datetime" variable, this is to make it more speedy to set the date I would like to check the year for. The main goal of this query is to show the average total for range of one year for all sales, and the "COUNT" for the year of sales done. What the first sub-query, that is located in the select clause, takes all the records from the "SalesOrderHeader" which is actually all the records from when the company started, then drops all the records that don't fall into the range, that was specified in the "SET" at the top.
The next sub-query is actally in the "FROM" clause, its actually used to make another table that takes all the records from the "SalesOrderHeader" and gets only the records in the range, same as the sub-query above. Then groups the records by there "CustomerID" this makes is so they are unique and then takes those grouped records and finds the "SUM" of the "TotalDue" column of these records. This sub-query used in the "FROM" clause makes it appear as a unique table, listing the "Total" sales of each "CustomerID" by taking this they can find out the average a person spends during the given year.

More To Come, CA.

Monday, March 28, 2011

What is a Subquery?

By the definition "Subquery or Inner query or Nested query is a query in a query."

SELECT studentName, major, studentId
FROM StudentTable
WHERE major IN 
 (SELECT major FROM MajorTable WHERE major = 'Awesome')

SELECT *
FROM (SELECT studentId FROM StudetTable WHERE studentId < 3)

declare @studentName varChar(50)
set @studentName = (SELECT top 1 studentName FROM StudentTable)

Wednesday, March 9, 2011

SQL-Hotel Reservations Assignment

Well here you go...
use Reservations  
   
 select C.name  
 from dbo.Hotel H  
 left outer join dbo.xrefHotexRoom xHR  
 on H.hotelId = xHR.hotelId  
 LEFT OUTER JOIN dbo.Room R  
 on xHR.roomId = R.roomId  
 left outer join dbo.xrefRoomxCustomer xRC  
 on R.roomId = xRC.roomId  
 left outer join dbo.Customer C  
 on xRC.customerId = C.customerId  
 where R.booked = 1  

select R.roomNumber , H.hotelname  
 from Room R  
 left outer join xrefHotexRoom xHR  
 on R.roomId = xHR.roomId  
 left outer join Hotel H  
 on xHR.hotelId = H.hotelId  
 where R.bed = 1 and R.smoking = 1 and R.fridge = 0 and R.hottub = 0  
 and H.bar = 0 and H.exercise = 0 and H.pets = 0 and H.[pool] = 1 and H.restaurant = 1 and H.wireless = 1  

select H.hotelname, r.roomNumber, rt.name, xHRT.rate  
 from Hotel H  
 left outer join xrefHotexRoom xHR  
 on H.hotelId = xHR.hotelId  
 left outer join Room R  
 on xHR.roomId = R.roomId  
 left outer join dbo.xrefRoomxType xRT  
 on R.roomId = xRT.roomId  
 left outer join dbo.RoomType RT  
 on xRT.typeId = RT.typeId  
 left outer join xrefHotelxRoomType xHRT  
 on xRT.typeId = xHRT.typeId AND H.hotelId = xHRT.hotelId  
 where R.booked = 0  
 order by xHRT.rate 

More to Come, CA.

Friday, March 4, 2011

ASP.Net Some Example Master File Layouts

Here are three variations of example Master page layouts that I have setup in asp.net, the pages are using divs and formating to create a table like layout of the information the page. Using <div> tags and CSS formatting I think you are able to more control over your codes visual representation.

This is a one column master page with the navigation menu setup down the left side of the content column.
 <%@ Master Language="C#" AutoEventWireup="true" CodeFile="SiteMaster1.master.cs" Inherits="SiteMaster" %>  
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">  
 <head runat="server">  
   <title></title>  
   <link href="~/Styles/Master1SS.css" rel="stylesheet" type="text/css" />  
   <asp:ContentPlaceHolder ID="HeadContent" runat="server">  
   </asp:ContentPlaceHolder>  
 </head>  
 <body>  
   <form runat="server">  
   <div id="wrapper">  
     <div id="headerWrapper">  
       <div style="vertical-align: middle;">  
         <h1>Media Center of The Universe</h1>  
       </div>  
     </div>  
     <div id="contentWrapper">  
       <div class="menu">  
         <asp:Menu ID="NavigationMenu" runat="server" Orientation="Vertical" StaticDisplayLevels="2" MaximumDynamicDisplayLevels="2">   
          <LevelMenuItemStyles>   
            <asp:MenuItemStyle CssClass="menuLevel"/>  
            <asp:MenuItemStyle CssClass="menuLevel"/>  
            <asp:MenuItemStyle CssClass="menuLevel"/>  
          </LevelMenuItemStyles>   
          <Items>   
            <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home" />  
            <asp:MenuItem NavigateUrl="~/Pages/Media.aspx" Text="Media">   
              <asp:MenuItem NavigateUrl="~/Pages/Pictures.aspx" Text="Pictures">  
                <asp:MenuItem NavigateUrl="~/Pages/PicsNew.aspx" Text="New Pictures" />  
                <asp:MenuItem NavigateUrl="~/Pages/PicsOld.aspx" Text="Old Pictures" />  
                <asp:MenuItem NavigateUrl="~/Pages/PicCategories.aspx" Text="Categories" />  
              </asp:MenuItem>  
              <asp:MenuItem NavigateUrl="~/Pages/Videos.aspx" Text="Videos" />   
            </asp:MenuItem>   
            <asp:MenuItem NavigateUrl="~/Pages/About.aspx" Text="About" />   
          </Items>   
         </asp:Menu>  
       </div>  
       <div class="content">  
         <asp:ContentPlaceHolder ID="MainContent" runat="server" />  
       </div>  
       <div class="clear" />  
     </div>  
     <div id="footer">  
       Media Center of The Universe Footer  
     </div>  
   </div>  
   </form>  
 </body>  
 </html>  
Here is what the above layout will look like with my CSS formatting.

Here is a layout for a two column master page with a variation in the menu placement, across the top of the two content column.
 <%@ Master Language="C#" AutoEventWireup="true" CodeFile="SiteMaster2.master.cs" Inherits="SiteMaster" %>  
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">  
 <head id="Head1" runat="server">  
   <title></title>  
   <link href="~/Styles/Master3SS.css" rel="stylesheet" type="text/css" />  
   <asp:ContentPlaceHolder ID="HeadContent" runat="server">  
   </asp:ContentPlaceHolder>  
 </head>  
 <body>  
   <form id="Form1" runat="server">  
   <div id="wrapper">  
     <div id="headerWrapper">  
       <h1>One Column Master</h1>  
     </div>  
     <div id="bodyWrapper">  
       <div class="menu">  
         <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false"  
           IncludeStyleBlock="true" Orientation="Vertical">  
           <Items>  
             <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home" />  
             <asp:MenuItem NavigateUrl="~/About.aspx" Text="About" />  
           </Items>  
         </asp:Menu>  
       </div>  
       <div id="contentWrapper">  
         <div class="content1">  
           <asp:ContentPlaceHolder ID="MainContent" runat="server" />     
         </div>  
         <div class="content2">  
           Hello  
         </div>  
         <div class="clear"></div>  
         <div id="footer">Footer</div>  
       </div>  
       <div class="clear"></div>  
     </div>  
   </div>  
   </form>  
 </body>  
 </html>  
Here is what the above layout looks like.


Here is a layout for another two column master page with the menu placement next to the left side of the two content columns.
 <%@ Master Language="C#" AutoEventWireup="true" CodeFile="SiteMaster2.master.cs" Inherits="SiteMaster" %>  
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">  
 <head id="Head1" runat="server">  
   <title></title>  
   <link href="~/Styles/Master3SS.css" rel="stylesheet" type="text/css" />  
   <asp:ContentPlaceHolder ID="HeadContent" runat="server">  
   </asp:ContentPlaceHolder>  
 </head>  
 <body>  
   <form id="Form1" runat="server">  
   <div id="wrapper">  
     <div id="headerWrapper">  
       <h1>Master Page Layout 3</h1>  
     </div>  
     <div id="bodyWrapper">  
       <div class="menu">  
         <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false"  
           IncludeStyleBlock="true" Orientation="Vertical">  
           <Items>  
             <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home" />  
             <asp:MenuItem NavigateUrl="~/About.aspx" Text="About" />  
           </Items>  
         </asp:Menu>  
       </div>  
       <div id="contentWrapper">  
         <div class="content1">  
           <asp:ContentPlaceHolder ID="MainContent" runat="server" />     
         </div>  
         <div class="content2">  
           Hello  
         </div>  
         <div class="clear"></div>  
         <div id="footer">Footer</div>  
       </div>  
       <div class="clear"></div>  
     </div>  
   </div>  
   </form>  
 </body>  
 </html>  
Here is the picture of the above layout.

More to Come, CA.

Friday, February 25, 2011

Left and Right Outer Joins...Awesome

Outer joins return all rows from one of the tables in the FROM clause, this is as long as those rows meet any WHERE search conditions. All rows are retrieved from the left table referenced with a left outer join, and all rows from the right table referenced in a right outer join.

Below is a "Left Outer Join" example that will be explained in extraneousness detail after the code.\/\/\/
 SELECT *  
 FROM Employee   
   LEFT OUTER JOIN Jobs  
   ON Employee.PayGrade = Jobs.PayGrade  
Since this is a LEFT OUTER JOIN so it will show all the "Employee" records, and all the "Jobs" records that have a "PayGrade" that is also in the same as the "Employee" "PayGrade".

Below is a "Right Outer Join" example that will be explained below the code.\/\/\/
 SELECT *  
 FROM Employee   
   RIGHT OUTER JOIN Jobs  
   ON Employee.PayGrade = Jobs.PayGrade    
A RIGHT OUTER JOIN is almost exactly the same as a LEFT OUTER JOIN, but instead of having all the records from the first table stated, "Employee", it will have all the records in "Jobs" instead, showing the "Employee" records with the same "PayGrade" of "Jobs".

More To Come, CA.

Wednesday, February 23, 2011

An Awesome SQL Assignment-Movie Quotes

Some Awesome assignment, database creation, table creations, and table filling.
 create database MovieQuote  
 GO  
   
 CREATE table actor(  
      actorId int Primary Key Identity(1,1),  
      actorName varchar(50)  
 )  
   
 CREATE table quote(  
      quoteId int Primary Key Identity(1,1),  
      quoteName varchar(50)  
 )  
   
 CREATE table movie(  
      movieId int Primary Key Identity(1,1),  
      movieName varchar(50),  
      xrefActorxQuote int  
 )  
   
 CREATE table xrefActorxQuote(  
      xrefActorxQuoteId int Primary Key Identity(1,1),  
      actorId int,  
      quoteId int  
 )  
 Go  
   
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (1, 1, 1)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (2, 7, 1)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (3, 8, 8)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (4, 9, 9)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (5, 10, 1)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (6, 41, 1)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (7, 42, 10)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (8, 43, 11)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (9, 44, 12)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (10, 45, 12)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (11, 46, 17)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (12, 47, 13)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (13, 48, 14)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (14, 49, 14)  
 INSERT xrefQuotexActor (xrefQuotexActorId, quoteId, actorId) VALUES (15, 50, 15)  
   
 INSERT xrefActorxMovie (xrefActorxMovie, actorId, movieId) VALUES (1, 14, 2)  
 INSERT xrefActorxMovie (xrefActorxMovie, actorId, movieId) VALUES (2, 15, 2)  
 INSERT xrefActorxMovie (xrefActorxMovie, actorId, movieId) VALUES (3, 12, 4)  
 INSERT xrefActorxMovie (xrefActorxMovie, actorId, movieId) VALUES (4, 16, 4)  
 INSERT xrefActorxMovie (xrefActorxMovie, actorId, movieId) VALUES (5, 17, 5)  
 INSERT xrefActorxMovie (xrefActorxMovie, actorId, movieId) VALUES (6, 10, 1)  
 INSERT xrefActorxMovie (xrefActorxMovie, actorId, movieId) VALUES (7, 1, 3)  
 INSERT xrefActorxMovie (xrefActorxMovie, actorId, movieId) VALUES (8, 8, 3)  
 INSERT xrefActorxMovie (xrefActorxMovie, actorId, movieId) VALUES (9, 9, 3)  
 INSERT xrefActorxMovie (xrefActorxMovie, actorId, movieId) VALUES (10, 11, 4)  
 INSERT xrefActorxMovie (xrefActorxMovie, actorId, movieId) VALUES (11, 13, 5)  
   
 INSERT quote (quoteId, quote) VALUES (1, 'Here''s looking at you, kid.')  
 INSERT quote (quoteId, quote) VALUES (7, 'endship.')  
 INSERT quote (quoteId, quote) VALUES (8, 'Play it, Sam. Play ''As Time Goes By.')  
 INSERT quote (quoteId, quote) VALUES (9, 'Round up the usual suspects.')  
 INSERT quote (quoteId, quote) VALUES (10, 'We''ll always have Paris.')  
 INSERT quote (quoteId, quote) VALUES (41, 'Of all the gin joints in all the towns in all the world, she walks into mine.')  
 INSERT quote (quoteId, quote) VALUES (42, 'I''m going to make him an offer he can''t refuse.')  
 INSERT quote (quoteId, quote) VALUES (43, 'Frankly, my dear, I don''t give a damn.')  
 INSERT quote (quoteId, quote) VALUES (44, 'After all, tomorrow is another day!')  
 INSERT quote (quoteId, quote) VALUES (45, 'As God is my witness, I''ll never be hungry again.')  
 INSERT quote (quoteId, quote) VALUES (46, 'Plastics.')  
 INSERT quote (quoteId, quote) VALUES (47, 'Mrs. Robinson, you''re trying to seduce me... Aren''t you?')  
 INSERT quote (quoteId, quote) VALUES (48, 'Toto, I''ve got a feeling we''re not in Kansas anymore')  
 INSERT quote (quoteId, quote) VALUES (49, 'There''s no place like home.')  
 INSERT quote (quoteId, quote) VALUES (50, 'I''ll get you, my pretty, and your little dog too!')  
   
 INSERT movie (movieId, movieName) VALUES (1, 'The Godfather')  
 INSERT movie (movieId, movieName) VALUES (2, 'The Wizard of Oz')  
 INSERT movie (movieId, movieName) VALUES (3, 'Casablanca')  
 INSERT movie (movieId, movieName) VALUES (4, 'Gone with the Wind')  
 INSERT movie (movieId, movieName) VALUES (5, 'The Graduate')  
   
 INSERT actor (actorId, actorName) VALUES (1, 'Humphrey Bogart')  
 INSERT actor (actorId, actorName) VALUES (8, 'Ingrid Bergman')  
 INSERT actor (actorId, actorName) VALUES (9, 'Claude Rains')  
 INSERT actor (actorId, actorName) VALUES (10, 'Marlon Brando')  
 INSERT actor (actorId, actorName) VALUES (11, 'Clark Gable')  
 INSERT actor (actorId, actorName) VALUES (12, 'Vivien Leigh')  
 INSERT actor (actorId, actorName) VALUES (13, 'Dustin Hoffman')  
 INSERT actor (actorId, actorName) VALUES (14, 'Judy Garland')  
 INSERT actor (actorId, actorName) VALUES (15, 'Margaret Hamilton')  
 INSERT actor (actorId, actorName) VALUES (16, 'Rhett Butler')  
 INSERT actor (actorId, actorName) VALUES (17, 'Mr. Maguire')  
   

That thing people do...

 select movieName, actorName, quote  
 From movie m  
      inner join xrefActorxMovie xam  
      on m.movieId = xam.movieId  
        
      inner join actor a  
      on xam.actorId = a.actorId  
        
      inner join xrefQuotexActor xqa  
      on a.actorId = xqa.actorId  
        
      inner join quote q  
      on xqa.quoteId = q.quoteId  
        
 Where actorName = 'Humphrey Bogart'  

Another thing people do...

 Select movieName, actorName, quote  
 From dbo.movie m  
      inner join dbo.xrefActorxMovie xAM  
      on m.movieId = xAM.movieId  
   
      inner join dbo.actor a  
      on xAM.actorId = a.actorId  
   
      inner join dbo.xrefQuotexActor xQA  
      on a.actorId = xQA.actorId  
   
      inner join dbo.quote q  
      on xQA.quoteId = q.quoteId  
        
 where movieName = 'Casablanca'  

The Last thing people do...

 Select actorName, quote, movieName  
 From actor a  
      inner join xrefQuotexActor xqa  
      on a.actorId = xqa.actorId  
        
      inner join quote q  
      on xqa.quoteId = q.quoteId  
        
      inner join xrefActorxMovie xam  
      on a.actorId = xam.actorId  
        
      inner join movie m  
      on xam.movieId = m.movieId  
 Where quote = 'Plastics.'  

More to come, CA. Sometime.

Monday, February 14, 2011

Asp.Net Form Validation...YAY!!!

Form validation in ASP.Net is so much easier than you would think, using just two tags you can check if a text box is null...\/\/\/
 <table>  
    <tr align="right">  
       <td>Description of File: </td>  
       <td>  
         <asp:TextBox id="txtName" runat="server" />  
       </td>  
       <td align="left">  
         <asp:RequiredFieldValidator id="valTxtName" ControlToValidate="txtName" ErrorMessage="Please enter your Name!" runat="server" />  
       </td>  
     </tr>  
     <tr>  
       <td colspan="2" align="center""><asp:Button ID="add" runat="server"   
           Text="Add Old Pic" onclick="add_Click" /></td>  
     </tr>  
 </table>  
As long you use the the "asp" tags, using "asp:TextBox" and set the id property of the text box, this will come into play in the "asp:RequiredFieldValidator". The asp validator can be any place on the form, and can be used to send a message if the validation fails, by still having a null value.

Saturday, February 12, 2011

SQL-Ice Cream Assignment--Part 2

The sale, distributors, and inventory queries of an ice cream shop database.\/\/\/

 Select flavName, brandName, saleScoops, salePrice, saleDate  
 From dbo.iceCreamSales S  
      inner join dbo.xrefIceCreamSalesxFlavorBrand xS  
      on S.saleId = xS.salesId  
      inner join dbo.xrefIceCreamFlavorxBrand xF  
      on xS.xrefFlavId = xF.xrefFlavId  
      inner join dbo.iceCreamFlavor F  
      on xF.flavId = F.flavId  
      inner join dbo.iceCreamBrand B  
      on xF.brandId = B.brandId  
 Go
This is the sales query, showing the sale, how many scoops, what date, and when a sale of a flavor and brand has happened.

 Select tubsOnHand, flavName, brandName  
 From dbo.iceCreamInventory I  
      Inner Join dbo.xrefIceCreamInventoryxFlavorBrand xI  
      on I.invenId = xI.invenId  
      inner join dbo.xrefIceCreamFlavorxBrand xF  
      on xI.xrefFlavId = xF.xrefFlavId  
      inner join dbo.iceCreamFlavor F  
      on xF.flavId = F.flavId  
      inner join dbo.iceCreamBrand B  
      on xF.brandId = B.brandId  
 Where tubsOnHand <= 1  
 Go
This is the Inventory query, showing where there is one or less tubs left on had for all flavor and brands.

 Select distrName, flavName, brandName  
 From iceCreamDistributor D  
      Inner Join dbo.xrefIceCreamDistributorxFlavorBrand xD  
      on D.distrID= xD.distrId  
      inner join dbo.xrefIceCreamFlavorxBrand xF  
      on xD.xrefFlavId = xF.xrefFlavId  
      inner join dbo.iceCreamFlavor F  
      on xF.flavId = F.flavId  
      inner join dbo.iceCreamBrand B  
      on xF.brandId = B.brandId  
 where B.brandId=1 and F.flavId=2  
 Go  
This is the Distriubtors query, found by brand and flavor combination.

Sunday, February 6, 2011

SQL-Ice Cream Assignment

The creation of a database, the creation of three tables, inserting so some records into the tables, an inner join to get the brands of a flavor from the tables using a cross reference, and another inner join to get the flavors of a brand from the tables using a cross reference.

 CREATE DATABASE ColdFusion  
 GO  
   
 USE ColdFusion  
 CREATE table iceCreamBrand(  
      brandId int Primary Key Identity(1,1),  
      brandName varchar(50)  
 )  
 CREATE table iceCreamFlavor(  
      flavorId int Primary Key Identity(1,1),  
      flavorName varchar(50)  
 )  
 CREATE table xrefIceCream(  
      flavorId int,  
      brandId int  
 )  
 Go  
   
 INSERT [xrefIceCream] ([flavorID], [brandID]) VALUES (1, 1)  
 INSERT [xrefIceCream] ([flavorID], [brandID]) VALUES (2, 1)  
 INSERT [xrefIceCream] ([flavorID], [brandID]) VALUES (3, 1)  
 INSERT [xrefIceCream] ([flavorID], [brandID]) VALUES (4, 2)  
 INSERT [xrefIceCream] ([flavorID], [brandID]) VALUES (5, 2)  
 INSERT [xrefIceCream] ([flavorID], [brandID]) VALUES (6, 2)  
 INSERT [xrefIceCream] ([flavorID], [brandID]) VALUES (7, 3)  
 INSERT [xrefIceCream] ([flavorID], [brandID]) VALUES (8, 3)  
 INSERT [xrefIceCream] ([flavorID], [brandID]) VALUES (9, 3)  
 INSERT [xrefIceCream] ([flavorID], [brandID]) VALUES (10, 4)  
 INSERT [xrefIceCream] ([flavorID], [brandID]) VALUES (11, 4)  
 INSERT [xrefIceCream] ([flavorID], [brandID]) VALUES (12, 4)  
 Go  
   
 INSERT [iceCreamFlavor] ([flavID], [flavName]) VALUES (1, N'Marshmallow Candy')  
 INSERT [iceCreamFlavor] ([flavID], [flavName]) VALUES (2, N'Jelly Bean')  
 INSERT [iceCreamFlavor] ([flavID], [flavName]) VALUES (3, N'Vanilla')  
 INSERT [iceCreamFlavor] ([flavID], [flavName]) VALUES (4, N'Chocolate')  
 INSERT [iceCreamFlavor] ([flavID], [flavName]) VALUES (5, N'Butter Pecan')  
 INSERT [iceCreamFlavor] ([flavID], [flavName]) VALUES (6, N'Strawberry')  
 INSERT [iceCreamFlavor] ([flavID], [flavName]) VALUES (7, N'Cookies and Cream')  
 INSERT [iceCreamFlavor] ([flavID], [flavName]) VALUES (8, N'Coffee')  
 INSERT [iceCreamFlavor] ([flavID], [flavName]) VALUES (9, N'Rocky Road')  
 INSERT [iceCreamFlavor] ([flavID], [flavName]) VALUES (10, N'Chocolate Marshmallow')  
 INSERT [iceCreamFlavor] ([flavID], [flavName]) VALUES (11, N'Cherry')  
 INSERT [iceCreamFlavor] ([flavID], [flavName]) VALUES (12, N'Chocolate Almond')  
 Go  
   
 INSERT [iceCreamBrand] ([brandID], [brandName]) VALUES (1, N'Baskin-Robbins')  
 INSERT [iceCreamBrand] ([brandID], [brandName]) VALUES (2, N'Ben and Jerry''s')  
 INSERT [iceCreamBrand] ([brandID], [brandName]) VALUES (3, N'Gay Lea')  
 INSERT [iceCreamBrand] ([brandID], [brandName]) VALUES (4, N'Healthy Choice')  
 Go  
   
 declare @flavorName varchar(50);  
 set @flavorName = 'Vanilla';  
   
 Select brandName, flavName  
 From iceCreamBrand B  
      Inner Join xrefIceCream X  
      on B.brandId=X.brandId  
           Inner join iceCreamFlavor F  
           on F.flavID=X.flavorID  
 Where flavName=@flavorName  
 Go  
   
 declare @brandName varchar(50);  
 set @brandName = 'Baskin-Robbins';  
   
 Select flavName, brandName  
 From iceCreamFlavor F  
      Inner Join xrefIceCream X  
      on F.flavID=x.flavorId  
           inner join iceCreamBrand B  
           on B.brandID = x.brandID   
 where brandName=@brandName  
 Go  

More to come, CA.

Wednesday, February 2, 2011

ASP.Net Menu Navigation

This time around we are going to look into the "Menu" control aspect of ASP.Net to create a navigation menu for a website. Posted below is a code snip-it of just a "Menu" control...
 <asp:Menu ID="NavigationMenu" runat="server" Orientation="Vertical" StaticDisplayLevels="2" MaximumDynamicDisplayLevels="2">  
     <LevelMenuItemStyles>  
         <asp:MenuItemStyle CssClass="menuLevel1"/>  
         <asp:MenuItemStyle CssClass="menuLevel2"/> 
         <asp:MenuItemStyle CssClass="menuLevel3"/>  
     </LevelMenuItemStyles>  
     <Items>  
         <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home" />
         <asp:MenuItem NavigateUrl="~/Media.aspx" Text="Media"> 
             <asp:MenuItem NavigateUrl="~/Pictures.aspx" Text="Pictures">
                 <asp:MenuItem NavigateUrl="~/PicsNew.aspx" Text="New Pictures" />
                 <asp:MenuItem NavigateUrl="~/PicsOld.aspx" Text="Old Pictures" />
             </asp:MenuItem>
             <asp:MenuItem NavigateUrl="~/Videos.aspx" Text="Videos" />  
         </asp:MenuItem>  
         <asp:MenuItem NavigateUrl="~/About.aspx" Text="About" />  
     </Items>  
 </asp:Menu>  
Now lets take a walk, to start we will look at the first tag, the "asp:Menu" tag, this tag will have everything about your menu control between the start and end tags. There are some very important properties included in this tag, like the "Orientation", "StaticDisplayLevels", and the "MaximumDynamicDisplayLevels" properties, the rest should all be review. To start the "Orientation" property is used to set the menu as a "Vertical" or "Horizontal" menu, as the values imply it will either have the menu bar spread out side-to-side on the web page or down to the bottom of the web page. The next two, the "StaticDisplayLevels" and "MaximumDynamicDispalyLevels" are kinda related in that they can be used to setup if the menu will "pop" out when the cursor is hovered over a menu item that has multiple levels or be "Static" on the page, so you can just click on the menu item. I will get into more of how to take care of this later in the post, but first I will talk about how to format the menu items.

The "LevelMenuItemStyles" tag is used to set the "CSS" formating in the menu by how the levels of the menu are deep. This means you can have a different format for each level of the menu to allow for a fancier menu style. On a note you have to have an "asp:MenuItemStyle" tag for each level of your menu control, if you don't have the same amount of tags setting a style from a "CSS" the missing styles will just be plain, blue text with a transparent background.

Now to the bulk of the "Menu" control, the "Items" tag, this is where all the navigation items of a menu will go. For ever "asp:MenuItem" in between the "Items" start and end tag, you will get click-able link to another page. The two main properties of an "asp:MenuItem" are the "NavigateUrl" property, which tells the link what page to route too, and the "Text" property, that holds the display name of the link. Looking at the example above you can see that some of the tags have the ending "/" inside the tag its self, and the others don't, this is how you make a dynamic menu. By making a start and end tag of a "Menu Item" you can set how many levels deep the menu will go, based on how many times you have nested the "Menu Item".

More to Come, CA.

Friday, January 28, 2011

Table Variable-Using Inner Join Select

Lets take a look at how to make two tables, that have a "Similar Column", joined together, by using a "Select" statement with an inner join...
 Declare @FamousPainters Table(  
      FP_id int PRIMARY KEY IDENTITY(1,1),  
      painterName nvarchar(25)  
 )  
   
 Declare @Paintings Table(  
      P_id int Primary Key Identity(1,1),  
      FP_id int,  
      paintingName nvarchar(35),  
      paintingYear nvarchar(15)  
 )  
   
 INSERT into @FamousPainters(painterName)    
 Values('Lenardo da Vinci')  
 INSERT into @FamousPainters(painterName)    
 Values('Michelagelo Buonarroti')  
 INSERT into @FamousPainters(painterName)    
 Values('Vincent van Gogh')  
   
 INSERT into @Paintings(FP_id,paintingName,paintingYear)  
 Values(1,'Portrait of Ginevra deBenci','1478-1480')  
 INSERT into @Paintings(FP_id,paintingName,paintingYear)  
 Values(1,'Mona Lisa','1503-1506')  
   
 INSERT into @Paintings(FP_id,paintingName,paintingYear)  
 Values(2,'Creation of Adam','Unknown')   
 INSERT into @Paintings(FP_id,paintingName,paintingYear)  
 Values(2,'Libyan Sibyl','Unknown')  
 INSERT into @Paintings(FP_id,paintingName,paintingYear)  
 Values(2,'Delphic Sibyl','Unknown')  
   
 INSERT into @Paintings(FP_id,paintingName,paintingYear)  
 Values(3,'Starry Night','1889')  
   
 SELECT painterName, paintingName, paintingYear  
 FROM @FamousPainters  
   Inner Join @Paintings  
     On [@FamousPainters].FP_id=[@Paintings].FP_id  
 Order By [@FamousPainters].painterName  
   
 GO  

First I created two "Table Variables" one a list of famous painters, with just the names of the painters and an id. The id of the famous painters will be the similar column of both tables, it can really be anything you want, but I chose this because it was less writing, I could of chose the painters name as the "Similar Column". The second "Table Variable" is a list of all the paintings with a primary key, a foreign key, that will be the key that relates to the painter of the painting, the painting name, and the year the painting was painted.

I then filled the tables with data, the first with three painters, and the other table with paintings relating to the three painters. After I ran a "SELECT" statement to pull the columns "painterName, paintingName, paintingYear" from both tables. I then have to specify my main table, and then the table i will join to it. After i have to tell it "ON" as in when the column "FP_id" of my "@FamousPainters" table equals my "@Paintings" "FP_id" column they will "Share" the data in both columns. I finish up by ordering it by the painters name.

CA.

Wednesday, January 26, 2011

Creation of a Frog Database

Here is a query for the creation of a database, the creation of a table and the filling of a table in the database for SQL Compact Edition...\/\/\/

 CREATE DATABASE USAFrogs  
 GO  
 USE [USAFrogs]  
 GO  
   
 CREATE TABLE Alaska(  
      id int PRIMARY KEY IDENTITY(1,1),  
      scientificName nvarchar(25),  
      redListStatus nvarchar(5),  
      vernacularName nvarchar(25),  
      family nvarchar(15)  
 )  
 GO  
   
 INSERT INTO Alaska (scientificName, redListStatus, vernacularName, family)  
 Values('Bufoboreas','NT','Western Toad','Bufonidae')  
 GO  
 INSERT INTO Alaska (scientificName,redListStatus,vernacularName,family)  
 Values('Pseudacris','LC','Pacific Treefrog','Hylidae')  
 GO  
 INSERT INTO Alaska (scientificName,redListStatus,vernacularName,family)  
 Values('Rana aurora','LC','Red-legged Frog','Ranidae')  
 GO  
 INSERT INTO Alaska (scientificName,redListStatus,vernacularName,family)  
 Values('Rana catesbeiana','LC','Bullfrog','Ranidae')  
 GO  
 INSERT INTO Alaska (scientificName,redListStatus,vernacularName,family)  
 Values('Rana luteiventris','LC','Columbia Spotted Frog','Ranidae')       
 GO  

More to Come, CA.

Monday, January 24, 2011

Create a database

This will create a database when executed in a database query...
 CREATE DATABASE your_db   
 GO  

More to Come, CA.

Friday, January 21, 2011

Table Variable-The Updating

This script will show the creation of a "Table Variable", the inserting of three records into that table, and then the changing of one record. The end of the script shows all the records currently in the table, with the changed  record.

  DECLARE @varTable table(    
  Id int IDENTITY(1,1),    
  UserName VARCHAR(25),    
  Passwd VARCHAR(15)    
  )    
   
  INSERT into @varTable(UserName,Passwd)    
  Values('Jib','JibsPasswd')    
   
  INSERT into @varTable(UserName,Passwd)    
  Values('Jax','JaxsPasswd')   
    
  INSERT into @varTable(UserName,Passwd)    
  Values('Who','WhosPasswd')   
    
  SELECT *  
  From @varTable  
    
  UPDATE @varTable  
  Set Passwd='awesome'  
  Where UserName='Jib'  
    
  SELECT *  
  From @varTable  
    
  GO    
    

More to Come, CA.

Table Variable-The Deletion

Here is the creation of a "Table Variable" table, the inserting of 3 records, and the deletion of one of those records.

  DECLARE @varTable table(  
  Id int IDENTITY(1,1),  
  UserName VARCHAR(25),  
  Passwd VARCHAR(15)  
  )  
    
  INSERT into @varTable(UserName,Passwd)  
  Values('Jib','JibsPasswd')  
    
  INSERT into @varTable(UserName,Passwd)  
  Values('Jax','JaxsPasswd')  
    
  INSERT into @varTable(UserName,Passwd)  
  Values('Who','WhosPasswd')  
    
  SELECT *   
  From @varTable 

  DELETE From @varTable  
  Where id=1  
    
  SELECT *   
  From @varTable  

  GO   

More to Come, CA.

Table Vairable-The Creation

This script creates a "Table Variable", then inserted 3 records into it the table, and selects all the records from the table.

  DECLARE @varTable table(   
  Id int IDENTITY(1,1),   
  UserName VARCHAR(25),   
  Passwd VARCHAR(15)   
  )   

  INSERT into @varTable(UserName,Passwd)   
  Values('Jib','JibsPasswd')   

  INSERT into @varTable(UserName,Passwd)   
  Values('Jax','JaxsPasswd')  
 
  INSERT into @varTable(UserName,Passwd)   
  Values('Who','WhosPasswd') 
  
  SELECT *
  From @varTable   
  
  GO    

More to come, CA.

Some Usefull Linux Terminal Commands

I have a few Linux Commands that i used that are very helpful.

 #yum search <name> -> Used to search what packages are available for anything you enter in "<name>".  
 #yum install <name> -> Used to install the package that is called "<name>".  
 #rm -rf <name> -> Will remove a whole directory without give any warnings ex. [y/n]  
 #git --bare init -> I use this to create a bare git repository in my current directory  
 #git update-server-info -> I use this command to setup my git repository for remote access  
 #chown -R "name:group" <dir> -> I use this command to change the ownership of a specified directory  
 #ls -al -> This command is useful when you need to know the access information of all directories and files of the current directory  
 #service <name> restart -> This is used to restart the "<name>" service  

CA

Thursday, January 20, 2011

SQL-Temp Table And Table Variable

What are the difference between the use of a SQL "Temporary Table" and "Table Variable"? Well lets take a look...
Temporary Table
The first thing to note is a "Temporary Table" is valid for a whole session. Here is a query you can try out to see the scope of where the "Temporary Table" exists...\/\/\/
 create table #tmpTable(i int)  
 insert into #tmpTable select 345
 Go  
 create table #tmpTable(i int)  
 insert into #tmpTable select 345  
 Go  
As you can see by executing the above query it will come up with an error. Your are still in the same session scope that the first "#tmpTable" was still in the database. The only way to make another Temporary Table in the same session is to "Drop Table <table name>" or completely exit out of the current session to get rid of saved temporary table. Also it is possible to add columns or records to a Temporary Table.

Table Variable
Here is a query you can try out to see the scope of where the "Temporary Table" exists...\/\/\/
 declare @varTable table(i int)  
 insert into @varTable select 45  
 GO  
 declare @varTable table(i int)  
 insert into @varTable select 45  
 GO  
If you executed the query you would find that you would not get an error when executing. This is because a "Table Variable" has a statement-level scope, as soon as the statement is executed the scope is lost, and also the declared "Table Variable". Different from a "Temporary Table" in that you cant really alter the "Table Variable".

More to come, CA.

Tuesday, January 18, 2011

The Basics of an ASP.Net Web Site

Am going to assume you just opened your first "ASP.NET Web Site" and see this window...\/\/\/\/

Am also assuming you have a basic understanding of the basic layout of the "MsV Web Developer 2010" to start lets look at the "Master Page" markup.

ASP Master Page
Lets start by going over the "Master Page" of ASP.Net...
  • The first to note is the file "Site.master" this is your "Master Page"
    • The "Master Page" is used like a template that the whole Web Site will follow, anything thats put in a "Master Page" markup will be included into every web page loaded by the browser.
    • If you "Double-Click" on the "Site.master" file something like this will come up...\/\/\/
     <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="SiteMaster" %>  
     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">  
     <head runat="server">  
       <title></title>  
       <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />  
       <asp:ContentPlaceHolder ID="HeadContent" runat="server">  
       </asp:ContentPlaceHolder>  
     </head>  
     <body>  
       <form runat="server">  
       <div class="page">  
         <div class="header">  
           <div class="title">  
             <h1>  
               My ASP.NET Application  
             </h1>  
           </div>  
           <div class="loginDisplay">  
             <asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">  
               <AnonymousTemplate>  
                 [ <a href="~/Account/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> ]  
               </AnonymousTemplate>  
               <LoggedInTemplate>  
                 Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!  
                 [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/"/> ]  
               </LoggedInTemplate>  
             </asp:LoginView>  
           </div>  
           <div class="clear hideSkiplink">  
             <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">  
               <Items>  
                 <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>  
                 <asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>  
               </Items>  
             </asp:Menu>  
           </div>  
         </div>  
         <div class="main">  
           <asp:ContentPlaceHolder ID="MainContent" runat="server"/>  
         </div>  
         <div class="clear">  
         </div>  
       </div>  
       <div class="footer">  
       </div>  
       </form>  
     </body>  
     </html>  
    

    You can have multiple "Master Page" files in a website project, you can think of these as multiple templates for different parts of your site, as long at the page points to the right "Master Page" then you will get that template for the page.

    How To:

    •  Right-Click project root->Add->New Item...
    • Select "Master Page"
    • Name the File
    • Click Add
    • And your done making a new "Master Page"

    There is a lot of different tags in this file, most are general xhtml tags, but a few are <asp...> tags used by ASP.Net. As I will go over next I will show how to add some dynamics to your website.

    ASP Content Place Holder Tag
    The <asp:ContentPlaceHolder...> tag is used for dynamic insertion of content form pages that are loaded by your web site. This tag it self is the link from to were your pages will insert the content into the "Master Page" of your website, so just inserting this in the master page will link the page to the template.

    Here is the syntax for inserting a new "Asp Content Place Holder" tag...\/\/\/
     <asp:ContentPlaceHolder ID="HeadContent" runat="server">    
      </asp:ContentPlaceHolder>   

    Here is some information on the attributes included in the default of the tag...
    • The "ID" attribute is set to "HeadContent" this helps it to create a link the pages with the "Master Page".
    • The "runat" attribute is used to tell where the information is to be processed. (CA-Note: A "runat" attribute is required for almost all <asp...> tags or you will get a compiler error if not included.)
    ASP Content Pages
    An ASP content page has a name like "Default.aspx" file name these pages have two main components.
    • The <%@ Page...> tag is used to setup the connection to the "Site.master" file so it can get its template for the web page.
    •  It also contatins a <asp:Content...> tag used to insert content of the page into the "Master Page". (CA-Note: Even if you try to include content outside the <asp:Content...> tags the site wont even compile.)
     <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"  
       CodeFile="Default.aspx.cs" Inherits="_Default" %>  
     <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">  
     </asp:Content>  
     <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">  
       <h2 style="color:red;" runat="server">  
         Welcome to ASP.NET!  
       </h2>  
       <p>  
         To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.  
       </p>  
       <p>  
         You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409"  
           title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.  
       </p>  
     </asp:Content>  
    

    Lets take a closer look at the <asp:Content...> tag like the one below...\/\/\/

     <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">   
       <h2 style="color:red;" runat="server">   
        Welcome to ASP.NET!   
       </h2>   
       <p>   
        To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.   
       </p>   
       <p>   
        You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409"   
         title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.   
       </p>   
      </asp:Content>   
    
    • The "ID" attribute is used for setting the unique name for the tag, can be used on the "Master Page" or different things to the content of the tag.
    • As before the "runat" attribute is used to set what side the tag is processed on, server or not.
    • As you can tell the "ContentPlaceHolderID" attribute is set to "MainContent" this means that for anything included in between the starting and ending tag will be sent to the "Master Page" to be displayed where a <asp:ContentPlaceHolder...> tag that has an "ID" of "MainContent". (CA-Note: If you dont have this inside the tag it will not compile and even if it could it would not make a link to the master page.)
    More to come, CA.

    Creating a ASP.Net Web Site

    How do you start an ASP.Net Web Site? Like This...

    On the "Start" page of  "Microsoft Visual Web Developer 2010 Express" you have two very common ways to create a "New Web Site"..
    1) Click "New Web Site..." on the "Start Page"
    2) Click "File->New Web Site..."

    This page should come up...\/\/\/\/

    To name the website project file, you will need to to into the "Web Location" path bar and change the ending of the "Path" from "/WebSite1" to what you would like the web site project to be named.

    This will create a very basic ASP.Net website...

    More to come, CA.