Click here to Skip to main content
15,886,798 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
hi friends please help me
i am using asp.net 3.5 and using i took a web project
i have a class which is UserControlEventArgs.cs which is
C#
using System;

/// <summary>
/// Jeff Kent - 11/14/2009
/// EVENT CLASS THAT ENCAPSULATES THE EVENT ARGUMENTS.
/// </summary>
public class UserControlEventArgs : EventArgs
{

  //CONSTRUCTOR USED TO DETERMINE IF A
  //RECORD INSERTION WAS SUCCESSFUL.
  public UserControlEventArgs(bool InsertComplete)
  {
    if (InsertComplete)
    {
      this.InsertComplete = true;
    }
    else
    {
      this.InsertComplete = false;
    }
  }

  private bool _InsertComplete;
  public bool InsertComplete{
    get { return _InsertComplete ; }
    set { _InsertComplete = value; }
  }

}

//DECLARE THE EVENT DELEGATE FOR THE CONTROL.
//NOTE HOW THE DELEGATE RESIDES OUTSIDE THE SCOPE OF THE CLASS.
public delegate void ClubInsertedEventHandler(object sender, UserControlEventArgs e);


And one web user control is WebUserControlAddUser.ascx

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

/// <summary>
/// Jeff Kent - 11/14/2009
/// SAMPLE WEB USER CONTROL WITH EVENT BUBBLING SUPPORT.
/// THE FORM VIEW CONTROL IS USED TO COLLECT AND PROCESS CLUB INFORMATION.
/// ONLY THE INSERT ITEM TEMPLATE IS USED IN THIS EXAMPLE.
/// </summary>
public partial class WebUserControlAddUser : System.Web.UI.UserControl
{

  //DECLARE THE DELEGATE VARIABLE.
  public event ClubInsertedEventHandler ClubInsertComplete;

  //PUT THE FORM VIEW INTO THE INSERT MODE 
  //EVERY TIME THE PAGE LOADS THE CONTROL.
  protected void FormView1_Load(object sender, EventArgs e)
  {
    FormView1.ChangeMode(FormViewMode.Insert);
  }

  // THE FORM VIEW CONTROL CAN BE TRICKY. 
  // THE WORK AROUND THE QUIRKS IS TO INTERCEPT THE ITEMCOMMAND EVENT
  // THEN USE THE SWITCH STRUCTURE TO CONTROL THE STATE OF THE CONTROL.
  protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
  {
      UserControlEventArgs args;
      switch (e.CommandName)
      {
        case "StartInsert":
          //NOT USED IN THIS IMPLEMENTATION.
          break;
        case "CommitInsert":
          InsertNewClub();
          FormView1.ChangeMode(FormViewMode.ReadOnly);

          //FIRE THE EVENT TO SEND NOTICE TO
          //THAT THE CLUB SUBBMISSION WAS SUCCESSFUL.
          args = new UserControlEventArgs(true);
          ClubInsertComplete(this, args);

          break;
        case "CancelInsert":
          FormView1.ChangeMode(FormViewMode.ReadOnly);
          FormView1.DataBind();

          //FIRE THE EVENT TO SEND NOTICE TO
          //THAT THE CLUB SUBBMISSION WAS CANCELLED.
          args = new UserControlEventArgs(false);
          ClubInsertComplete(this, args);

          break;
        default:
          break;
    }
  }

  //OBTAIN THE DATA FROM THE FORM 
  //AND INSERT IT INTO THE DATA TABLE.
  protected void InsertNewClub()
  {
    TextBox tb;

    tb = (TextBox)FormView1.FindControl("ClubID");
    int ClubID = Convert.ToInt32(tb.Text);
    tb = (TextBox)FormView1.FindControl("ClubName");
    string ClubName = tb.Text;
    tb = (TextBox)FormView1.FindControl("URL");
    string url = tb.Text;

    ClubList.AddClub(ClubID, ClubName, url);
  }
}




i am confused about assembly reference ."you are missing a using directive or an assembly reference"
why the error comes when i run the program

i have made that line bold please check
Posted
Updated 10-Jul-12 9:30am
v2
Comments
[no name] 10-Jul-12 15:07pm    
Your code works perfectly fine for me. Are you sure you are not getting an "Object reference not set to an instance of an object" error?
[no name] 10-Jul-12 15:41pm    
"you are missing a using directive or an assembly reference"
why the error comes when i run the program

No you will absolutely not get that error in the manner in which you describe. "Missing a using directive etc." is a compile time error not a run time error.
Sander Rossel 10-Jul-12 17:48pm    
That bold line was a hard find...

The error means that you are trying to use a class or method in your program that is not defined, because (as it clearly states) "you are missing a using directive or an assembly reference". Check the documentation for the class you are trying to access and fix the reference.
 
Share this answer
 
I got this error a couple of times. Every time I got it it meant I was building in .NET X Client Profile. Make sure you don't select Client Profile, but the regular .NET version. You can find it in your Project Options under the Compile tab.
Other than that the error is pretty self-explanatory. Hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900