?
Solved

'__o' is not declared. It may be inaccessible due to its protection level.

Posted on 2010-11-20
5
Medium Priority
?
2,960 Views
Last Modified: 2013-11-07
Hi

I have 10-15 errors of this kind

'__o' is not declared. It may be inaccessible due to its protection level.

at my <%: start tags

Im new to this, so why do i get this error and how do i fix it.
I have looked at the numbers 0 that its not the letter oO, and the other way bag
And its ok...

    <tr>
            <td colspan="3" align="right">Netto:</td>
            <td align="right">
            <%: (Model.Cart.ComputeTotalValue() * 0.8D).ToString("c")%>
            </td>
    </tr>
    <tr>
            <td colspan="3" align="right">Moms 25%:</td>
            <td align="right">
            <%: (Model.Cart.ComputeTotalValue() * 0.2D).ToString("c")%>
            </td>
    </tr> 

Open in new window


This is my Index.aspx site that shows the items and price
<%@ Page Language="vb" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Store.WebUI.Models.CartIndexViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
NetButik : Din Kurv
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Din Kurv</h2>
<table width="90%" align="center">
    <thead><tr>
        <th align="center">Antal</th>
        <th align="left">Vare</th>
        <th align="right">Pris</th>
        <th align="right">Total</th>
    </tr></thead>
    <tbody>
    <% For Each line In Model.Cart.Lines%>
        <tr>
            <td align="center"><%: line.Quantity %></td>
            <td align="left"><%: line.Product.Name %></td>
            <td align="right"><%: line.Product.Price.ToString("c") %></td>
            <td align="right">
            <%: (line.Quantity*line.Product.Price).ToString("c") %>
            </td>
            <td>
            <% Using Html.BeginForm("RemoveFromCart", "Cart")%>
            <%: Html.Hidden("ProductId", line.Product.ProductID) %>
            <%: Html.HiddenFor(Function(x) x.ReturnUrl)%>
            <input type="submit" value="Slet Vare" />
            <% End Using%>
            </td>
        </tr>
    <% Next%>
    </tbody>
    <tfoot>
    <tr>
            <td colspan="3" align="right">Netto:</td>
            <td align="right">
            <%: (Model.Cart.ComputeTotalValue() * 0.8D).ToString("c")%>
            </td>
    </tr>
    <tr>
            <td colspan="3" align="right">Moms 25%:</td>
            <td align="right">
            <%: (Model.Cart.ComputeTotalValue() * 0.2D).ToString("c")%>
            </td>
    </tr>
    <tr>
            <td colspan="3" align="right">Total:</td>
            <td align="right">
            <%: Model.Cart.ComputeTotalValue().ToString("c") %>
            </td>
    </tr></tfoot>
</table>
<p align="center" class="actionButtons">
<a href="<%: Model.ReturnUrl %>">Gå tilbage og handle.</a>
<%: Html.ActionLink("Check out now", "CheckOut") %>
</p>
</asp:Content>

Open in new window


the ComputeTotalValue function is from here
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text

Namespace Store.WebUI.Entities
    Public Class Cart
        Private m_lines As New List(Of CartLine)()
        Public ReadOnly Property Lines() As IList(Of CartLine)
            Get
                Return m_lines.AsReadOnly()
            End Get
        End Property

        Public Sub AddItem(ByVal product As Product, ByVal quantity As Integer)
            Dim line = m_lines.FirstOrDefault(Function(x) x.Product.ProductID = product.ProductID)
            If line Is Nothing Then
                m_lines.Add(New CartLine() With { _
                 .Product = product, _
                 .Quantity = quantity _
                })
            Else
                line.Quantity += quantity
            End If
        End Sub

        Public Function ComputeTotalValue() As Decimal
            Return m_lines.Sum(Function(l) l.Product.Price * l.Quantity)
        End Function

        Public Sub Clear()
            m_lines.Clear()
        End Sub

        Public Sub RemoveLine(ByVal product As Product)
            m_lines.RemoveAll(Function(l) l.Product.ProductID = product.ProductID)
        End Sub

        Public Property i() As Integer
            Get
                Return m_i
            End Get
            Set(ByVal value As Integer)
                m_i = value
            End Set
        End Property
        Private m_i As Integer
    End Class

    Public Class CartLine
        Public Property Product() As Product
            Get
                Return m_Product
            End Get
            Set(ByVal value As Product)
                m_Product = value
            End Set
        End Property
        Private m_Product As Product
        Public Property Quantity() As Integer
            Get
                Return m_Quantity
            End Get
            Set(ByVal value As Integer)
                m_Quantity = value
            End Set
        End Property
        Private m_Quantity As Integer
    End Class
End Namespace

Open in new window


0
Comment
Question by:tjgrindsted
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 34180859
Is '__o'  defined on the master page?
If so, it is private to the page?
You need to make a public property: (I assume __o is a button, change it as needed)
        public Button MyO
        { get { return __o; } }
0
 

Author Comment

by:tjgrindsted
ID: 34180961
Hi Mas oz2003

No its not a button, i dont know where thats comming from..

My Master site is like this
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site.master.vb" Inherits="System.Web.Mvc.ViewMasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
    <link rel="Stylesheet" href="../../Content/Site.css" />
    <style type="text/css">
        DIV#categories A {
        font: bold 12px verdana,arial,helvetica,sans-serif; display: block;
        text-decoration: none; padding: 3px; color: Black;
        border-bottom: 1px solid silver;
        }
        DIV#categories A.selected { background-color: #666; color: White; }
        DIV#categories A:hover { background-color: #CCC; }
        DIV#categories A.selected:hover { background-color: #666; }
    </style>
</head>
    <body>
        <div id="header">
        <%  If Not (TypeOf ViewContext.Controller Is Store.WebUI.Store.WebUI.Controllers.CartController) Then
                Html.RenderAction("Summary", "Cart")
            End If
 %>
            <div class="title">NetButik</div>
        </div>
        <div id="categories">
            <% Html.RenderAction("Menu", "Nav") %>
        </div>
        <div id="content">
            <asp:ContentPlaceHolder ID="MainContent" runat="server" />
        </div>
    </body>
</html>

Open in new window

0
 

Assisted Solution

by:tjgrindsted
tjgrindsted earned 0 total points
ID: 34181004
I get the errors after i have converted the files from C# to VB.Net
The C# code is like this.
dont know if its a converting error...

index.aspx
<table width="90%" align="center">
    <thead><tr>
        <th align="center">Antal</th>
        <th align="left">Vare</th>
        <th align="right">Pris</th>
        <th align="right">Total</th>
    </tr></thead>
    <tbody>
    <% foreach(var line in Model.Cart.Lines) { %>
        <tr>
            <td align="center"><%: line.Quantity %></td>
            <td align="left"><%: line.Product.Name %></td>
            <td align="right"><%: line.Product.Price.ToString("c") %></td>
            <td align="right">
            <%: (line.Quantity*line.Product.Price).ToString("c") %>
            </td>
            <td>
            <% using(Html.BeginForm("RemoveFromCart", "Cart")) { %>
            <%: Html.Hidden("ProductId", line.Product.ProductID) %>
            <%: Html.HiddenFor(x => x.ReturnUrl) %>
            <input type="submit" value="Slet Vare" />
            <% } %>
            </td>
        </tr>
    <% } %>
    </tbody>
    <tfoot>
    <tr>
            <td colspan="3" align="right">Netto:</td>
            <td align="right">
            <%: (Model.Cart.ComputeTotalValue()*0.80m).ToString("c")%>
            </td>
    </tr>
    <tr>
            <td colspan="3" align="right">Moms 25%:</td>
            <td align="right">
            <%: (Model.Cart.ComputeTotalValue()*0.20m).ToString("c") %>
            </td>
    </tr>
    <tr>
            <td colspan="3" align="right">Total:</td>
            <td align="right">
            <%: Model.Cart.ComputeTotalValue().ToString("c") %>
            </td>
    </tr></tfoot>
</table>

Open in new window


and the other file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Store.Domain.Entities
{
    public class Cart
    {
        private List<CartLine> lines = new List<CartLine>();
        public IList<CartLine> Lines { get { return lines.AsReadOnly(); } }

        public void AddItem(Product product, int quantity)
        {
            var line = lines
                .FirstOrDefault(x => x.Product.ProductID == product.ProductID);
                if (line == null)
                    lines.Add(new CartLine { Product = product, Quantity = quantity });
                else
                    line.Quantity += quantity;
        }

        public decimal ComputeTotalValue()
        { 
            return lines.Sum(l => l.Product.Price * l.Quantity); 
        }

        public void Clear()
        { 
            lines.Clear(); 
        }

        public void RemoveLine(Product product)
        {
            lines.RemoveAll(l => l.Product.ProductID == product.ProductID);
        }

        public int i { get; set; }
    }

    public class CartLine
    {
        public Product Product { get; set; }
        public int Quantity { get; set; }
    }
}

Open in new window

0
 

Accepted Solution

by:
tjgrindsted earned 0 total points
ID: 34181130
0
 

Author Closing Comment

by:tjgrindsted
ID: 34211388
i found the link myself
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

770 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