Thread View: borland.public.csharpbuilder.aspdotnet.general
2 messages
2 total messages
Started by MobileD
Thu, 05 Jan 2006 23:59
Need help with Objects/Event interphase
Author: 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;
}
}
}
}
Re: Need help with Objects/Event interphase
Author: OD
Date: Wed, 15 Feb 2006 20:22
Date: Wed, 15 Feb 2006 20:22
24 lines
2488 bytes
2488 bytes
MobileD a οΏ½crit :
> Please help me understand why the code below
> will not work (see Button1_Click event)
> If (label1.BackColor.Blue);
> {
> label1.Text = "This is Blue" ;
> label1.BackColor = Blue;
> }
> Else;
> {
> label1.Text = "This is Red" ;
> label1.BackColor = Red;
The test is testing nothing ...
You must rewrite the "if" :
if (label1.Backcolor == Color.Blue) ...
--
Olivier Dahan
MK Query Builder
www.e-naxos.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads