Article View: borland.public.csharpbuilder.aspdotnet.general
Article #46Need help with Objects/Event interphase
From: MobileD
Date: Thu, 05 Jan 2006 23:59
Date: Thu, 05 Jan 2006 23:59
73 lines
3015 bytes
3015 bytes
I am trying to learn C# and ASP.NET. I am familiar with Object Oreneted
Programming; I was using Delphi but I never did quite get Class and Type. I
purchase a programming course from AppDev on C# done by Jessie Liberty and
have a much better understanding but still can quite get pass the Class
threshold. I have written a few same Webpages with C# code behind trying to
get up to speed but am a little hung up on accessing properties on the
Webpage from the code behind. Please help me understand why the code below
will not work (see Button1_Click event)
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace testcase
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label label1;
protected System.Web.UI.WebControls.Button button1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1.Click += new System.EventHandler(this.button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
If (label1.BackColor.Blue);
{
label1.Text = "This is Blue" ;
label1.BackColor = Blue;
}
Else;
{
label1.Text = "This is Red" ;
label1.BackColor = Red;
}
}
}
}
Technical Details
Message-ID:
<43bdb230$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 124d48,26b6807a820d90a8,start X-Google-Attributes: gid124d48,public X-Google-Language: ENGLISH,ASCII-7-bit From: "MobileD" <MobileD@charter.net> Newsgroups: borland.public.csharpbuilder.aspdotnet.general Subject: Need help with Objects/Event interphase Date: Thu, 5 Jan 2006 15:59:11 -0800 Lines: 75 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 66.189.220.233 Message-ID: <43bdb230$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1136505392 66.189.220.233 (5 Jan 2006 15:56:32 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail