Hey,
what is the using declaration? (I know what you mean, but, my problem is:)
My control is an ascx file. I havn't compiled it (and am not sure how to compile it). I'm not sure where to declare the namespace in a custom control either. Also, I may be confusing the issue. I'm not sure of the difference between a custom control and a user control.
Could you give me a really basic example, or a link to a basic tutorial on it? (I've been searching and searching, and everything I find is just about programmatically including the controls, arg, lol).
Thanks a lot for your help.
-Ashleigh
(Infact, here is a very simplified version of my code)
ascx control
<%@ Control Language="c#" %>
<%@ import Namespace="System.Collections" %>
<%@ import Namespace="System.Web.Security" %>
<%@ import Namespace="System.Configuration" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<%@ Import Namespace="System.Web" %>
<script runat="server">
public class AdvTextBox : System.Web.UI.UserControl
{
}
public string Fish
{
get {return "hello";}
set {Response.Write(value);}
}
private void Page_Load(object sender, EventArgs e)
{
}
</script>
ASPX Page
<%@ Page Src="test.cs" Inherits="test" ValidateRequest="false" Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="myControls" TagName="AdvTextBox" Src="AdvTextBox.ascx" %>
<html>
<head>
<title>Advanced TextBox</title>
</script>
</head>
<body>
<form runat="server" enctype="multipart/form-data">
<myControls:AdvTextBox id="mcHeader" strCode="jHeader" width="400" height="600" Runat="Server"/>
</form>
</body>
</html>
CODEBEHIND for ASPX (I dont' know what to do in here, I'll paste my latest attempt)
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Data;
public class test: Page {
protected TextBox txtBox;
//protected Control myControl;
protected UserControl mcHeader;
//protected AdvTextBox mcHeader;
/* PAGE LOAD */
void Page_Load(Object sender , EventArgs e)
{
mcHeader = (UserControl)LoadControl("advTextBox.ascx");
//mcHeader.InitializeAsUserControl(this);
mcHeader.Fish="hello"; //<--Error occurs on this line
if(!IsPostBack)
{
}
}
}
Compiler Error Message:'System.Web.UI.UserControl' does not contain a definition for 'Fish'
Thanks again