2.0 Control issues

Strange_Will

Member
Joined
Jan 31, 2006
Messages
14
Programming Experience
1-3
Default.aspx
VB.NET:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Title</title>
</head>
<body>
    <form id="form_main" runat="server">
        <asp:Panel ID="Main" runat="server" />
    </form>
</body>
</html>

Default.aspx.vb
VB.NET:
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
                Handles Me.Load
        Dim no_NoteAdd As New Control
        no_NoteAdd = LoadControl("App_Controls\noteadd.ascx")
        Main.Controls.Add(no_NoteAdd)
    End Sub
End Class

NoteAdd.ascx
VB.NET:
<%@ Control Language="VB" ClassName="noteadd" CodeFile="~/App_Controls/noteadd.ascx.vb" Inherits="noteadd"%>
<table>
    <tr>
        <td>
            <asp:label id="test" runat="server"/>
        </td>
        <td>
            A CONTROL!
        </td>
    </tr>
</table>

Noteadd.ascx.vb
VB.NET:
Imports Microsoft.VisualBasic
Imports System
Imports System.Web
Imports System.Web.UI

Public Class noteadd : Inherits Control
    Public Shared _message As String

    Public Shared Property Message() As String
        Get
            Return _message
        End Get
        Set(ByVal value As String)
            _message = value
        End Set
    End Property

    Protected Sub Render(ByVal Output As HtmlTextWriter)
        test.Text = "This is a test on test.text"
        'test.text = _message
    End Sub

End Class


I've been trying custom controls and I'm having an issue with a few things here, first I get an error:

C:\Documents and Settings\User\My Documents\Visual Studio 2005\WebSites\test1\App_Controls\noteadd.ascx.vb(1): error ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).

And second

I want to set _message to a value, and have it change on the control, I've been reading up a little on properties, but this is a mess and I can't seem to get it right and I can't find a site that is clear on how this works.

Any ideas?
 
Back
Top