Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Apress committed Oct 11, 2016
0 parents commit a0c74a2
Show file tree
Hide file tree
Showing 524 changed files with 18,776 additions and 0 deletions.
Binary file added 9781590598917.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions Beginning ASP.NET 3.5/Chapter03/App_Code/Product.cs
@@ -0,0 +1,62 @@
using System;

// Define the delegate that represents the event.
public delegate void PriceChangedEventHandler();

public class Product
{
private string name;
private decimal price;
private string imageUrl;

public string Name
{
get
{ return name; }
set
{ name = value; }
}

// Define the event.
public event PriceChangedEventHandler PriceChanged;

public decimal Price
{
get
{ return price; }
set
{
price = value;

// Fire the event, provided there is at least one listener.
if (PriceChanged != null)
{
PriceChanged();
}
}
}

public string ImageUrl
{
get
{ return imageUrl; }
set
{ imageUrl = value; }
}

public string GetHtml()
{
string htmlString;
htmlString = "<h1>" + name + "</h1><br>";
htmlString += "<h3>Costs: " + price.ToString() + "</h3><br>";
htmlString += "<img src='" + imageUrl + "' />";
return htmlString;
}

public Product(string name, decimal price)
{
Name = name;
Price = price;
}
}

19 changes: 19 additions & 0 deletions Beginning ASP.NET 3.5/Chapter03/Default.aspx
@@ -0,0 +1,19 @@
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">
private void Page_Load(object sender, EventArgs e)
{
Product saleProduct = new Product("Kitchen Garbage", 49.99M);
saleProduct.ImageUrl = "garbage.jpg";
Response.Write(saleProduct.GetHtml());
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Product Test</title>
</head>
<body></body>
</html>
Binary file added Beginning ASP.NET 3.5/Chapter03/Garbage.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 113 additions & 0 deletions Beginning ASP.NET 3.5/Chapter03/Web.config
@@ -0,0 +1,113 @@
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" compilerOptions="/warnaserror-" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" compilerOptions="/optioninfer+" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
</compiler>
</compilers>
</system.codedom>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
30 changes: 30 additions & 0 deletions Beginning ASP.NET 3.5/Chapter05/CurrencyConverter.aspx
@@ -0,0 +1,30 @@
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="CurrencyConverter.aspx.cs" Inherits="CurrencyConverter" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Currency Converter</title>
</head>
<body>
<form ID="Form1" method="post" runat="server">

<div style="border-right: thin ridge; padding-right: 20px; border-top: thin ridge;
padding-left: 20px; padding-bottom: 20px; border-left: thin ridge; width: 531px;
padding-top: 20px; border-bottom: thin ridge; font-family: Verdana; background-color: #FFFFE8">
Convert: &nbsp;
<input type="text" ID="US" runat="server" style="width: 102px" />&nbsp; U.S. dollars to &nbsp;
<select ID="Currency" runat="server" />
<br /><br />
<input type="submit" value="OK" ID="Convert" runat="server" OnServerClick="Convert_ServerClick" />
<input type="submit" value="Show Graph" ID="ShowGraph" runat="server" OnServerClick="ShowGraph_ServerClick" />
<br /><br />
<img ID="Graph" alt="Currency Graph" scr="" runat="server" />
<br /><br />
<div style="font-weight: bold" ID="Result" runat="server"></div>
</div>
</form>
</body>
</html>
45 changes: 45 additions & 0 deletions Beginning ASP.NET 3.5/Chapter05/CurrencyConverter.aspx.cs
@@ -0,0 +1,45 @@
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public partial class CurrencyConverter : System.Web.UI.Page
{
protected void Page_Load(Object sender, EventArgs e)
{
if (this.IsPostBack == false)
{
// The HtmlSelect control accepts text or ListItem objects.
Currency.Items.Add(new ListItem("Euros", "0.85"));
Currency.Items.Add(new ListItem("Japanese Yen", "110.33"));
Currency.Items.Add(new ListItem("Canadian Dollars", "1.2"));
}
Graph.Visible = false;
}
protected void Convert_ServerClick(object sender, EventArgs e)
{
decimal amount;
bool success = Decimal.TryParse(US.Value, out amount);
if (success)
{
// Retrieve the selected ListItem object by its index number.
ListItem item = Currency.Items[Currency.SelectedIndex];

decimal newAmount = amount * Decimal.Parse(item.Value);
Result.InnerText = amount.ToString() + " U.S. dollars = ";
Result.InnerText += newAmount.ToString() + " " + item.Text;
}
else
{
Result.InnerText = "The number you typed in was not in the correct format. ";
Result.InnerText += "Use only numbers.";
}
}

protected void ShowGraph_ServerClick(object sender, EventArgs e)
{
Graph.Src = "Pic" + Currency.SelectedIndex.ToString() + ".png";
Graph.Visible = true;
}
}
22 changes: 22 additions & 0 deletions Beginning ASP.NET 3.5/Chapter05/CurrencyConverter.html
@@ -0,0 +1,22 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Currency Converter</title>
</head>
<body>
<form action="post">
<div style="border-right: thin ridge; padding-right: 20px; border-top: thin ridge;
padding-left: 20px; padding-bottom: 20px; border-left: thin ridge; width: 531px;
padding-top: 20px; border-bottom: thin ridge; font-family: Verdana; height: 211px;
background-color: #FFFFE8">
Convert:&nbsp;
<input type="text" />
&nbsp;U.S. dollars to Euros.
<br /><br />
<input type="submit" value="OK" />
</div>
</form>
</body>
</html>
12 changes: 12 additions & 0 deletions Beginning ASP.NET 3.5/Chapter05/Global.asax
@@ -0,0 +1,12 @@
<%@ Application Language="C#" %>

<script runat="server">
protected void Application_OnEndRequest()
{
Response.Write("<hr>This page was served at " +
DateTime.Now.ToString());
}
</script>
21 changes: 21 additions & 0 deletions Beginning ASP.NET 3.5/Chapter05/HtmlEncodeTest.aspx
@@ -0,0 +1,21 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="HtmlEncodeTest.aspx.cs" Inherits="HtmlEncodeTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form ID="form1" runat="server">
<div>
<h1>Properly encoded:</h1>
<div ID="ctrl2" runat="server"/>
<br /><hr /><br />
<h1>Incorrectly encoded:</h1>
<div ID="ctrl1" runat="server"/>
</div>
</form>
</body>
</html>
19 changes: 19 additions & 0 deletions Beginning ASP.NET 3.5/Chapter05/HtmlEncodeTest.aspx.cs
@@ -0,0 +1,19 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class HtmlEncodeTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ctrl1.InnerHtml = "To <b>bold</b> text use the <b> tag.";
ctrl2.InnerHtml = "To <b>bold</b> text use the " + Server.HtmlEncode("<b>") + " tag.";
}
}
28 changes: 28 additions & 0 deletions Beginning ASP.NET 3.5/Chapter05/ImageTest.aspx
@@ -0,0 +1,28 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ImageTest.aspx.cs" Inherits="ImageTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form ID="form1" runat="server">
<div>

<h1>Click on the Image </h1>

<input type="image"
src="button.png"
ID="ImgButton"
runat="server" OnServerClick="ImgButton_ServerClick" />
<br />
<div ID="Result"
runat="server"/>


</div>
</form>
</body>
</html>

0 comments on commit a0c74a2

Please sign in to comment.