markoniuss
markoniuss

Reputation: 451

Reference in ASPX file is not working as in ASPX.CS file

I am using http://code.google.com/p/google-api-for-dotnet/ Google API for .NET.

I added DLL file reference to project and address it using using Google.API.Search; Search.aspx.cs file and it works completely fine.

using Google.API.Search;

namespace ASP._8
{
    public partial class Search : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public static IList<IWebResult> Search()
        {
            GwebSearchClient client = new GwebSearchClient(@"http://www.google.com/");
            IList<IWebResult> results = client.Search("Google API for .NET", 32);
            return results;
        }
    }
}

Trouble is when I try to access same code in Search.aspx file. I've got this errors

Error 4 The name 'Google' does not exist in the current context c:\Users\Martinek\Documents\My\Learning.Dot.Net\ASP.8\ASP.8\Search.aspx 12 15 ASP.8
Error 5 The type or namespace name 'IWebResult' could not be found (are you missing a using directive or an assembly reference?) c:\Users\Martinek\Documents\My\Learning.Dot.Net\ASP.8\ASP.8\Search.aspx 13 18 ASP.8

Any ideas? Attaching Search.aspx

<%  using Google.API.Search;
    foreach (IWebResult a in ASP._8.Search.Search()){ %>

Upvotes: 0

Views: 1284

Answers (1)

WojtekT
WojtekT

Reputation: 4775

Try adding:

<%@import Namespace="Google.API.Search" %>

right below <@page...

in Search.aspx file.

Upvotes: 1

Related Questions