asp.net page not seeing custom control, can't set properties

M

Mad Scientist Jr

I have a asp.net.vb page with a custom control, and for some reason
the codebehind is not seeing the control.



The control is in a file "page_footer.ascx" in the root of the site
and contains the following:

<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="page_footer.ascx.vb" Inherits="mysite1.page_footer"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<script language="VB" runat="server">
Public sFooterText As String = ""
</script>
<table border="0" width="100%" cellSpacing="0" cellPadding="0">
<tr>
<td align="right"><font
class="copy"><%=sFooterText%></font>&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>



The control is defined in my ASPX page (also in the root of the site)
at the top of the HTML as:

<%@ Register TagPrefix="site1" TagName="page_footer"
Src="page_footer.ascx" %>




An instance is defined in the HTML body as:

<site1:page_footer id="page_footer_1" runat="server"
sFooterText="Copyright 2004"></site1:page_footer><br>



In the codebehind I try this:

page_footer_1.sFooterText = "Copyright 2003"
^^^^^^^^^^^^^

but "page_footer_1" is underlined in blue and I get the error 'Name
"page_footer_1" is not declared.'



What am I doing wrong?
 
A

Alessandro Zifiglio

declare your control in your codebehind class first, just like you would do
with any asp.net control. Otherwise it is undefined ;P

public page_footer_1 as page_footer

page_footer_1.sFooterText = "Copyright 2003"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top