Solved

asp.net calling variable undeclared when is clearly declared

Posted on 2013-01-16
7
241 Views
Last Modified: 2013-01-25
In the following code the varaible 'strVisDiscount','strVisDisconn','strVisActive' are all listed as undeclared, but the above examples 'encString' to 'strBGroup' are not throwing the same error.
   <input type="hidden" name="session" value="<%=encString %>" />
            <input type="hidden" name="billerId" value="<%=strBiller %>" />
            <input type="hidden" name="billerGroupId" value="<%=strBGroup %>" />
        </td>
    </tr>
 
    <tr>
        <td align="left">
            <b>Billed Services</b>:
            <asp:datalist id="ddlConnections" runat="server" Width="100%" cellpadding="4" Visible="true">
                <HeaderTemplate>
                    <td valign="top" width="14%" align="left">
                        <b>Service</b>
                    </td>
                    <td valign="top" width="14%" align="left">
                        <b>Equipment ID</b>
                    </td>
                    <td valign="top" width="14%" align="left">
                        <b>Rate</b>
                    </td>
                    <td valign="top" width="14%" align="left">
                        <b><%=strVisDiscount%></b>
                    </td>
                    <td valign="top" width="14%" align="left">
                        <b>Connected</b>
                    </td>
                    <td valign="top" width="14%" align="left">
                        <b><%=strVisDisconn %></b>
                    </td>
                    <td valign="top" width="14%" align="left">
                        <b><%=strVisActive %></b>

Open in new window



Declaration code here:

#Region "Private Members"

        Private strTemplate As String
        Private strConnectionTemplate As String
        Private strBillTemplate As String
        Public encString As String = ""
        Public strBiller As String = ""
        Public strBGroup As String = ""
        Public strEBillStat As String
        Public strVisDiscount As String = "Discount"
        Public strVisDisconn As String = "Disconnected"
        Public strVisActive As String = "Active"

#End Region

Open in new window


Why arn't they all being considered declared and how do I fix it?
0
Comment
Question by:UnderSeven
  • 3
  • 3
7 Comments
 
LVL 21

Expert Comment

by:masterpass
ID: 38785054
try something like this

Public Shared strVisDiscount As String = "Discount"
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 38785072
Is it just the editor or is it a compilation error?
try to recompile as sometimes the editor doesn't pickup things instantly...
0
 

Author Comment

by:UnderSeven
ID: 38787232
I tried loading this ascx file into my default.aspx and got this error:

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'Cogsdale.Modules.ViewCogsdale'.

Source Error:


Line 1:  <%@ Control language="vb" Inherits="Cogsdale.Modules.ViewCogsdale" Codebehind="ViewCogsdale.ascx.vb" AutoEventWireup="false" Explicit="True" %>
Line 2:  <%@ Register TagPrefix="dnn" TagName="Audit" Src="~/controls/ModuleAuditControl.ascx" %>
Line 3:  <asp:panel ID="pnlUse" runat="server">
 

So it's failing to load the code behind file, but I can't see why.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 41

Expert Comment

by:guru_sami
ID: 38788362
What type of project is that? Website or WebApplication?
Can we see the code-behind as well please...
0
 

Author Comment

by:UnderSeven
ID: 38794507
It's a web application.  The whole code behind is over 300 lines, here is everything leading up to those definitions:

Imports DotNetNuke
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection

Namespace Cogsdale.Modules

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' The ViewDynamicModule class displays the content
    ''' </summary>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Partial Class ViewCogsdale
        Inherits Entities.Modules.PortalModuleBase
        Implements Entities.Modules.IActionable

#Region "Private Members"

        Private strTemplate As String
        Private strConnectionTemplate As String
        Private strBillTemplate As String
        Public encString As String = ""
        Public strBiller As String = ""
        Public strBGroup As String = ""
        Public strEBillStat As String
        Public strVisDiscount As String = "Discount"
        Public strVisDisconn As String = "Disconnected"
        Public strVisActive As String = "Active"

#End Region

Open in new window

0
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 38807733
1: Add the name of your application to Inherits like:

Inherits="YourWebApplicationName.Cogsdale.Modules.ViewCogsdale"

Open in new window


2: Add Public in your class definition in your code-behind
Public Partial Class ViewCogsdale

Open in new window

0
 

Author Closing Comment

by:UnderSeven
ID: 38818755
This solved my problem and another I was having.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to go to Web page 2 52
.Net application crashing 6 21
Check if number is currency 15 29
dynamic menu in asp.net c# 11 29
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now