G
Guest
I was getting the following error after compiling the C# source file with
VS.NET 2003, Any help will be appreciated.
Many thanks!
Surjeet Gill
Details:
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.
Compiler Error Message: CS0234: The type or namespace name 'Global' does not
exist in the class or namespace 'System.Web.UI.WebControls.PlaceHolder' (are
you missing an assembly reference?)
Source Error:
Line 26:
Line 27: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
Line 28: public class Global_asax : PlaceHolder.Global {
Line 29:
Line 30: private static bool __initialized = false;
Source File: c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\chapter02_placeholder\3f5aa4a9\6f93a474\mzryuqmu.0.cs Line: 28
This was the only C# source file in the project.
// File Placeholder.aspx.cs
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 PlaceHolder
{
/// <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.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox txtName;
protected System.Web.UI.WebControls.DropDownList ddlDays;
protected System.Web.UI.WebControls.Panel pnlDynamic;
// Use the Page_Load event to load the dynamically created
// controls so that they are available prior to rendering
private void Page_Load(object sender, System.EventArgs e)
{
// Get the value selected by user in the dropdown list
int intDays = Convert.ToInt32(ddlDays.SelectedItem.Value);
// Create textboxes to allow entering the
// travel expenses for each travel day
for (int i = 1; i <= intDays; i++)
{
LiteralControl lcExpenseCaption = new LiteralControl();
lcExpenseCaption.Text =
String.Format("Travel Expense for Day-{0} ", i);
// Create a textbox control
TextBox txtExpense = new TextBox();
// Set the ID property of the textbox
txtExpense.ID = String.Format("Expense{0}", i);
HtmlControl lcBreak = new HtmlGenericControl("br");
pnlDynamic.Controls.Add(lcExpenseCaption);
// Add the textbox to the panel
// if you omit this step, textbox is
// created but not displayed
pnlDynamic.Controls.Add(txtExpense);
pnlDynamic.Controls.Add(lcBreak);
}
// Display a linkbutton that allow users to
// post the expenses after they have entered the data
if(intDays>0)
{
LinkButton lbtnSubmit = new LinkButton();
lbtnSubmit.Text = "Submit Expenses";
// Add an event handler to the dynamically created
// link button
lbtnSubmit.Click += new EventHandler(lbtnSubmit_Click);
pnlDynamic.Controls.Add(lbtnSubmit);
HtmlControl lcBreak = new HtmlGenericControl("br");
pnlDynamic.Controls.Add(lcBreak);
}
}
// Handles the Click event for the dynamically
// created link button
private void lbtnSubmit_Click(object sender, System.EventArgs e)
{
double dblExpenses = 0;
int intDays = Convert.ToInt32(ddlDays.SelectedItem.Value);
// Find sum of all expenses
for (int i = 1; i <= intDays; i++)
{
// Find control in the collection of controls
// contained by the panel
TextBox txtExpense = (TextBox)
pnlDynamic.FindControl(String.Format("Expense{0}", i));
dblExpenses += Convert.ToDouble(txtExpense.Text);
}
// Display the results
Label lblResults = new Label();
lblResults.Text = String.Format(
"{0}, a sum of ${1} has been credited to your account",
txtName.Text, dblExpenses);
pnlDynamic.Controls.Add(lblResults);
}
#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.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
VS.NET 2003, Any help will be appreciated.
Many thanks!
Surjeet Gill
Details:
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.
Compiler Error Message: CS0234: The type or namespace name 'Global' does not
exist in the class or namespace 'System.Web.UI.WebControls.PlaceHolder' (are
you missing an assembly reference?)
Source Error:
Line 26:
Line 27: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
Line 28: public class Global_asax : PlaceHolder.Global {
Line 29:
Line 30: private static bool __initialized = false;
Source File: c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\chapter02_placeholder\3f5aa4a9\6f93a474\mzryuqmu.0.cs Line: 28
This was the only C# source file in the project.
// File Placeholder.aspx.cs
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 PlaceHolder
{
/// <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.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox txtName;
protected System.Web.UI.WebControls.DropDownList ddlDays;
protected System.Web.UI.WebControls.Panel pnlDynamic;
// Use the Page_Load event to load the dynamically created
// controls so that they are available prior to rendering
private void Page_Load(object sender, System.EventArgs e)
{
// Get the value selected by user in the dropdown list
int intDays = Convert.ToInt32(ddlDays.SelectedItem.Value);
// Create textboxes to allow entering the
// travel expenses for each travel day
for (int i = 1; i <= intDays; i++)
{
LiteralControl lcExpenseCaption = new LiteralControl();
lcExpenseCaption.Text =
String.Format("Travel Expense for Day-{0} ", i);
// Create a textbox control
TextBox txtExpense = new TextBox();
// Set the ID property of the textbox
txtExpense.ID = String.Format("Expense{0}", i);
HtmlControl lcBreak = new HtmlGenericControl("br");
pnlDynamic.Controls.Add(lcExpenseCaption);
// Add the textbox to the panel
// if you omit this step, textbox is
// created but not displayed
pnlDynamic.Controls.Add(txtExpense);
pnlDynamic.Controls.Add(lcBreak);
}
// Display a linkbutton that allow users to
// post the expenses after they have entered the data
if(intDays>0)
{
LinkButton lbtnSubmit = new LinkButton();
lbtnSubmit.Text = "Submit Expenses";
// Add an event handler to the dynamically created
// link button
lbtnSubmit.Click += new EventHandler(lbtnSubmit_Click);
pnlDynamic.Controls.Add(lbtnSubmit);
HtmlControl lcBreak = new HtmlGenericControl("br");
pnlDynamic.Controls.Add(lcBreak);
}
}
// Handles the Click event for the dynamically
// created link button
private void lbtnSubmit_Click(object sender, System.EventArgs e)
{
double dblExpenses = 0;
int intDays = Convert.ToInt32(ddlDays.SelectedItem.Value);
// Find sum of all expenses
for (int i = 1; i <= intDays; i++)
{
// Find control in the collection of controls
// contained by the panel
TextBox txtExpense = (TextBox)
pnlDynamic.FindControl(String.Format("Expense{0}", i));
dblExpenses += Convert.ToDouble(txtExpense.Text);
}
// Display the results
Label lblResults = new Label();
lblResults.Text = String.Format(
"{0}, a sum of ${1} has been credited to your account",
txtName.Text, dblExpenses);
pnlDynamic.Controls.Add(lblResults);
}
#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.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}