| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Get control of your email attachments. Connect all your Gmail accounts and in less than 2 minutes, Dokkio will automatically organize your file attachments. You can also connect Dokkio to Drive, Dropbox, and Slack. Sign up for free.

View
 

Lecture - XML-Reflection-Inheritance

Page history last edited by Christopher Cole 6 years, 5 months ago

 XML - Inheritance - Reflection

 

 

Prerequisites

 

Part of Topic - Creating a Single Table Database Object Storage

 

Topic - Getting Started with Web Form Applications

 

next video: Lecture - XML-Reflection-Inheritance Part 2

 

Summary

 

Topics Covered in this Video;

 

-XML
-Reflection
-Handling Dangerous Request Forms
-ValidateRequest
-SamplePropertiesInherited
-tbResults
-\n
-asXML

 

Video 

 

http://online1.daytonastate.edu/player2.php?id=3a30be93eb45566a90f4e95ee72a089a 

 

 

Reference Materials

 

Class Code for SampleProperties

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Reflection;
namespace DatabaseSample1.App_Code
{
    public class SampleProperties
    {
        private string myName;
        public string Name
        {
            get { return myName; }
            set { myName = value; }
        }
        private string myDescription;
        public string Description
        {
            get { return myDescription; }
            set { myDescription = value; }
        }
        public string asXML()
        {
            string s = String.Empty;
            string fc = this.GetType().ToString();
            while (fc.Contains("."))
            {
                fc = fc.Substring(fc.IndexOf(".")+1);
            }
            s += "<" + fc + ">\n"; 
            foreach(var property in this.GetType().GetProperties())
            {
                s += " <" + property.Name + ">";
                s += property.GetValue(this);
                s += "</" + property.Name + ">";
                s += "\n";
            }
            s += "</" + fc + ">"; 
            return s;
        }
    }
    public class SamplePropertiesInherited : SampleProperties
    {
        private string myContent;
        public string Content
        {
            get { return myContent; }
            set { myContent = value; }
        }
    }
} 

 

Code for Form Creation

    Name: <asp:TextBox ID="tbName" runat="server"></asp:TextBox><br />
    Description: <asp:TextBox ID="tbDescription" runat="server"></asp:TextBox><br />
    <asp:Button ID="btnGo" runat="server" Text="Go" OnClick="btnGo_Click" /><br />
    Content: <asp:TextBox ID="tbContent" runat="server"></asp:TextBox><br />
    <asp:Button ID="btnGo2" runat="server" Text="Go" OnClick="btnGo2_Click" /><br />
    <asp:TextBox ID="tbResults" runat="server" TextMode="MultiLine" Height="200" Width="400"></asp:TextBox> 

 

Code for Buttons

 

protected void btnGo_Click(object sender, EventArgs e)
        {
            SampleProperties s = new SampleProperties
            {
                Name = tbName.Text,
                Description = tbDescription.Text
            };
            tbResults.Text = s.asXML();
        }
        protected void btnGo2_Click(object sender, EventArgs e)
        {
            SamplePropertiesInherited s = new SamplePropertiesInherited
            {
                Name = tbName.Text,
                Description = tbDescription.Text,
                Content = tbContent.Text
            };
            tbResults.Text = s.asXML();
        } 

 

 

Additional Information

 

 

COP 4834 Lectures Page

Comments (0)

You don't have permission to comment on this page.