Difference between revisions of "OOP Class8"

esse quam videri
Jump to: navigation, search
 
(16 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:OOP]]
+
[[Category:IAM Classes]]
 
+
MIDTERM
==About aspx==
 
 
 
[[Open you website as VS Project]]
 
 
 
{{Anatomy of an aspx page}}
 
 
 
==Simple Aspx Page==
 
 
 
http://iam.colum.edu/oop/classsource/class8/Aspx/hello.aspx [http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class8/Aspx/hello.aspx hello.aspx]
 
 
 
http://iam.colum.edu/oop/classsource/class8/Aspx/hello2.aspx
 
[http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class8/Aspx/hello2.aspx hello2.aspx]
 
 
 
http://iam.colum.edu/oop/classsource/class8/Aspx/Label.aspx
 
[http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class8/Aspx/Label.aspx Label.aspx]
 
 
 
In class
 
Build three hello aspx pages similar to the ones above
 
 
 
==Dogs on the web==
 
[http://iam.colum.edu/oop/browser/browser.aspx?f=/classsource/class8/DogWeb DogWeb]
 
 
 
 
 
 
 
{{HTML and HTTP}}
 
 
 
 
 
http://iam.colum.edu/oop/classsource/class9/htmlForms.html [http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class9/htmlForms.html htmlForms.html - source]
 
 
 
==Courses on the Web==
 
[http://iam.colum.edu/oop/browser/browser.aspx?f=/classsource/class8/StudentWeb Student Web]
 
 
 
==Response Object==
 
 
 
Response.Write()
 
 
 
http://iam.colum.edu/oop/classsource/class10/Response/Response1.aspx
 
[http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class10/Response/Response1.aspx Response1.aspx - source]
 
 
 
Response.End()
 
 
 
http://iam.colum.edu/oop/classsource/class10/Response/Response2.aspx
 
[http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class10/Response/Response2.aspx Response2.aspx - source]
 
 
 
Response.Clear()
 
 
 
http://iam.colum.edu/oop/classsource/class10/Response/ResponseClear.aspx
 
[http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class10/Response/ResponseClear.aspx ResponseClear.aspx - source]
 
 
 
Response.Flush()
 
 
 
http://iam.colum.edu/oop/classsource/class10/Response/ResponseFlush.aspx
 
[http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class10/Response/ResponseFlush.aspx ResponseFlush.aspx - source]
 
 
 
 
 
===Debugging with response object===
 
 
 
Using the response buffer can be extreemely usefull for debugging. Sometime you may have to setup a small debug system to help catch errors in object that do not inherit from System.UI.Page.
 
 
 
Response.Flush()
 
 
 
http://iam.colum.edu/oop/classsource/class10/Response/ResponseDebug.aspx
 
[http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class10/Response/ResponseDebug.aspx ResponseDebug.aspx - source]
 
 
 
==Home Work==
 
 
 
Convert one of your classes to work as an aspx page.
 
 
 
Have a nice break....
 
 
 
 
 
 
 
 
 
==Web Forms==
 
Examples of Web Forms
 
 
 
http://iam.colum.edu/oop/classsource/class9/aspForms.aspx [http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class9/aspForms.aspx aspForms.aspx - Source]
 
 
 
'''todo''' examples of all the html elements and how they react to form submits
 
 
 
==Persisting Data==
 
 
 
===POST and GET===
 
 
 
an asps page posting to itself
 
 
 
 
 
 
 
==Events in c# on the web==
 
 
 
Event handlers
 
 
 
OnClick
 
 
 
http://iam.colum.edu/oop/classsource/class9/events/events1.aspx
 
[http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class9/events/events1.aspx events1.aspx - source]
 
 
 
OnCommand
 
 
 
http://iam.colum.edu/oop/classsource/class9/events/events2.aspx
 
[http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class9/events/events2.aspx events2.aspx - source]
 
 
 
http://iam.colum.edu/oop/classsource/class9/events/events3.aspx
 
[http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class9/events/events3.aspx events3.aspx - source]
 
 
 
==Home Work==
 
 
 
Create a web page with a button that uses your class.
 
 
 
Create a windows form with a button the uses your class.
 
 
 
<csharp>
 
using System;
 
using System.Collections.Generic;
 
using System.ComponentModel;
 
using System.Data;
 
using System.Drawing;
 
using System.Text;
 
using System.Windows.Forms;
 
 
 
namespace WindowsDog
 
{
 
    public partial class Form1 : Form
 
    {
 
        Dog fido;
 
       
 
        public Form1()
 
        {
 
            InitializeComponent();
 
            fido = new Dog();
 
        }
 
 
 
        private void btnBark_Click(object sender, EventArgs e)
 
        {
 
            lblBark.Text = fido.Bark();
 
        }
 
 
 
 
 
        public class Dog
 
        {
 
            public string Name; // the dog's name
 
            public int Age; // the dog's age
 
            public int Weight; // the dog's weight
 
            public string BarkSound; // the sound of the dog's bark
 
 
 
            public Dog()
 
            {
 
                BarkSound = "Woof!!!";
 
            }
 
 
 
            public string Bark()
 
            {
 
                return this.BarkSound;
 
            }
 
            public void Eat()
 
            {
 
                //put eat code here
 
            }
 
        }
 
    }
 
}
 
</csharp>
 
 
 
<csharp>
 
&lt;%@ Page language="c#" debug="True" trace="false"%&gt;
 
 
 
&lt;script language="c#" runat="server"&gt;
 
   
 
    Dog fido;
 
   
 
    public void Page_Load()
 
    {
 
        fido = new Dog();
 
       
 
       
 
    }
 
 
 
    public void Button1_OnClick(Object sender, EventArgs e)
 
    {
 
        Response.Write("Hello from Button1_OnClick");
 
        lblBark.Text = fido.Bark();
 
    }
 
 
 
 
 
    public class Dog
 
    {
 
        public string Name; // the dog's name
 
        public int Age; // the dog's age
 
        public int Weight; // the dog's weight
 
        public string BarkSound; // the sound of the dog's bark
 
 
 
        public Dog()
 
        {
 
            BarkSound = "Woof!!!";
 
        }
 
 
 
        public string Bark()
 
        {
 
            return this.BarkSound;
 
        }
 
        public void Eat()
 
        {
 
            //put eat code here
 
        }
 
    }
 
&lt;/script&gt;
 
 
 
&lt;html&gt;
 
&lt;head&gt;&lt;title&gt;Test&lt;/title&gt;
 
&lt;/head&gt;
 
&lt;body&gt;
 
&lt;form runat="server"&gt;
 
test
 
    &lt;div id="div1" runat="server" style="background-color:Fuchsia"&gt;Hello in div&lt;/div&gt;
 
    &lt;asp:Label ID="lblBark" runat="server" &gt;&lt;/asp:Label&gt;
 
    &lt;br /&gt;
 
   
 
   
 
   
 
    &lt;asp:Button ID="Button1" OnClick="Button1_OnClick" runat="server" Text="Bark" /&gt;
 
&lt;/form&gt;
 
&lt;/body&gt;
 
&lt;/html&gt;
 
</csharp>
 

Latest revision as of 16:31, 10 June 2019

MIDTERM