473,396 Members | 1,886 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,396 software developers and data experts.

Name is not declared

I'm getting a BC30451: Name 'pageID' is not declared.

I have a user control that contains a simple condition to display one row or
another like:

<% If x = 1 Then %>
....some html...
<% Else %>
....some html...
<% End If %>

The control is used to in two different .aspx pages (e.g. first.aspx and
second.aspx). In each .aspx page, I've tried to set this variable right
after Private Sub Page_Load in the code-behind page to no avail...such as:

Public Class WebForm1
Inherits System.Web.UI.Page
Web Form Designer Generated Code

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Dim x As Integer = 10000

End Class

--
_____
DC G
Nov 18 '05 #1
1 3743
Hi, DC Gringo

Although your design is wrong, the solution is the following:

Create a property x of type Integer in the class of the usercontrol. Also a
public field of the class will work, but it is one of the worst things you
can do in the OOP world.
Assign this property (or field) from the Page in the Page_Load method.

Now, the good design:

Put the part between <% If x = 1 Then %> and <% Else %> in one
Panel/PlaceHolder/whatever container control with runat="server" and the
part between <% Else %> and <% End If %> in another container control with
runat="server" and visible="false". Remove <% If x = 1 Then %>, <% Else %>
and <% End If %>
In the class of the usercontrol add a method to switch the visibilities,
i.e.:

Public Sub SwitchVisibility(ByVal showFirstPanel As Boolean)
panel1.Visible = showFirstPanel
panel2.Visible = Not(showFirstPanel)
End Sub

Call this method on the instance of the usercontrol from the Page_Load of
the Page with the parameter you need.

Greetings
Martin
"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:eU**************@TK2MSFTNGP10.phx.gbl...
I'm getting a BC30451: Name 'pageID' is not declared.

I have a user control that contains a simple condition to display one row or another like:

<% If x = 1 Then %>
...some html...
<% Else %>
...some html...
<% End If %>

The control is used to in two different .aspx pages (e.g. first.aspx and
second.aspx). In each .aspx page, I've tried to set this variable right
after Private Sub Page_Load in the code-behind page to no avail...such as:

Public Class WebForm1
Inherits System.Web.UI.Page
Web Form Designer Generated Code

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Dim x As Integer = 10000

End Class

--
_____
DC G

Nov 18 '05 #2

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

Similar topics

4
by: Dan Jacobson | last post by:
Using <A name="x_y-z"></A>, I even get nervous about the _ and -. w3-recs/RECS/html4/struct/links.html seems to say all of ascii is cool and beyond. Anyway, just what is the safe range for...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
3
by: Mark Oliver | last post by:
Hi, Is there any way to get the declaration name of a parameter either through reflection, StackFrame, or something else? Thanks, Mark
0
by: Guoqi Zheng | last post by:
Dear sir, I am very new to asp.net. I often meet a problem of name 'xxx' is not declared. can some one tell me what is the problem? For example, my following code gives me an error of "Name...
2
by: TJS | last post by:
it says the name is not declared, but it is how can I fix this ? Compiler Error Message: BC30451: Name 'arrReportsList' is not declared. ========================== if...
13
by: Don | last post by:
How do I get an Enum's type using only the Enum name? e.g. Dim enumType as System.Type Dim enumName as String = "MyEnum" enumType = ???(enumName)
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
2
by: Renilkumar | last post by:
Hello, I have successfully migrated asp.net application built in VS2003/1.1 to VS2005/2.0 in my local machine. It runs good without any errors. However If I copy the application into the shared...
4
by: andrew | last post by:
Hi, I have routinely added anchors to pages using both name and id: <a name="example" id="example"></a> under the possibly mistaken assumption that at some stage "name" might be deprecated...
0
by: padmagvs | last post by:
I have a wsdl something like this <?xml version="1.0" ?> <definitions targetNamespace="http://abc.com/namespace/wsif/samples/abc" xmlns:tns="http://abc.com/namespace/wsif/samples/abc"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.