473,382 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

problem with user control

I am having problems setting a asp user control's property from code.
I have an asp.net page and have a user control "page_footer" which has
a property sFooterText. Here is the control:

<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="page_footer.ascx.vb" Inherits="Site1.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 at the top of my aspx page as so:

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

Everything works great when i set the property explicitly on the page,
such as:

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

However if i try to set it from codebehind's Page Load with a line
such as:

page_footer_1.sFooterText = "Copyright 2004"

the "page_footer_1" is underlined in blue, with a message "Name
'page_footer_1 is not declared."

Help me, Obi Wan.
Jul 21 '05 #1
1 1150
In case anyone else has this problem, I found out what was wrong.

1. in the codebehind of the aspx page that includes the control,
before pageinit, i needed to (manually) add:

Protected WithEvents page_footer_1 As site1.page_footer

2. in the user control ascx itself, you can't put the property
declaration in a <script> tag. WRONG:

<script language="VB" runat="server">
Public sFooterText As String = ""
</script>

instead, it has to go in the code behind, above Private Sub Page_Load.
RIGHT:

Public sFooterText As String = ""
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marko | last post by:
Please, can anyone help me... I have problem with VisualStudio.NET instalation: First step is OK (framework...), but when instalation of .NET begin, after some time I get message "INSTALATION...
1
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the...
5
by: | last post by:
Hi, I'm trying to use the cookie munging session handling behaviour of asp.net instead of cookies themselves as I'm finding quite a few people are barring cookies (especially AOL users). If I...
7
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am have facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web...
9
by: Anders K. Jacobsen [DK] | last post by:
Hi I have this that adds some usercontrol (UCTodays.ascx) to a placeholder foreach(A a in B){ UCTodays ucline = (UCTodays )LoadControl("UCTodays.ascx");...
1
by: Steve Booth | last post by:
I have a web form containing a button that when selected adds a user control to a place holder. The user control contains a button. The first time the user control is added the contained button...
5
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in...
1
by: Jeff | last post by:
Hey ..NET 2.0 I've created a User Control which contain a DataGridView. This User Control is displayed on a TabPage. This TabPage is added to the TabControl during runtime. The problem is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.