---
title: "ascx"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/70554-ascx"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "icaaq"
published: "2003-03-09T14:44:47.000Z"
updated: "2003-03-10T20:55:27.000Z"
replies: 5
views: 411
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/70554-ascx"
---

# ascx

## #1 — icaaq, 2003-03-09T14:44Z

När jag skapar en usercontrol (\*.ascx) i VS.NET så skapar VS denna kod:

```
[red]
namespace office.left_ascx
{
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;
	[b]using Icaaq.Office;[/b]

	/// <summary>
	///		Summary description for userinfo.
	/// </summary>
	public abstract class userinfo : System.Web.UI.UserControl
	{

		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);
		}
		
		///		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
	}
}
[/red]
```

Men hur ska jag skriva för att komma åt funktionerna i Icaaq.Office??
Om jag skriver som jag gjort nu så får jag:
**The type or namespace name 'Office' does not exist in the class or namespace 'office.Icaaq' (are you missing an assembly reference?)**

Mvh icaaq

Permalänk: https://www.webforum.nu/p/70554

## #2 — icaaq, 2003-03-09T14:49Z

Jag kan ju säga att om jag tar bort

```
[red]
namespace office.left_ascx
[/red]
```

så fungerar det *"som det ska"*

mvh icaaq

Permalänk: https://www.webforum.nu/p/974051

## #3 — NETwork, 2003-03-10T09:23Z

Skapa en instans av din usercontrol så kan du nå alla funktioner:

```
UserControl uc = new UserControl();
uc.myFunction();
```

Din usercontrol är en klass precis som vilken som helst och du använder den likadant!

Permalänk: https://www.webforum.nu/p/974487

## #4 — icaaq, 2003-03-10T18:46Z

Jag får det inte att fungera......
kan du förklara lite mer ingående på min kod ovanför??

mvh icaaq

Permalänk: https://www.webforum.nu/p/974904

## #5 — NETwork, 2003-03-10T20:41Z

Missuppfattade visst frågan, sorry! Du måste lägga till en referens till den assembly (.dll) som innehåller dina klasser (högerklicka på References i solution explorern och leta upp din dll).

Permalänk: https://www.webforum.nu/p/974994

## #6 — icaaq, 2003-03-10T20:55Z

ok......testar

Mvh icaaq

Permalänk: https://www.webforum.nu/p/975009

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/70554-ascx
