Namespaces og Web Service..
Jeg har lidt problemer med et namespace... Side 1 ser sådan her ud..:<%@ Page language="c#" Codebehind="GoogleSearch.aspx.cs" AutoEventWireup="false" Inherits="CodeBank.Google.GoogleSearch" %>
<%@ Import Namespace="CodeBank.Google" %>
<HTML>
<body bgcolor="#ffffff">
<form id="GoogleSearch" method="post" runat="server">
<h2>Google Search Web Service</h2>
<table border="0" width="400">
<tr>
<td width="30%"><b>Search Text</b></td>
<td width="70%"><asp:TextBox ID="txtSearchText" Runat="server" /></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><asp:Button ID="btnSearch" Runat="server" Text="Search Google!" /></td>
</tr>
</table>
<asp:Panel ID="pnlResults" Runat="server" Visible="False">
<P> </P>
<H2>Results:</H2>
<P>
<asp:DataList id="dlResults" runat="server" CellSpacing="0" CellPadding="4">
<ItemTemplate>
<a href='<%# ((ResultElement)Container.DataItem).URL %>' title='<%# ((ResultElement)Container.DataItem).summary %>'>
<%# ((ResultElement)Container.DataItem).title %>
</a>
</ItemTemplate>
</asp:DataList>
<P>Total Results Found:
<asp:Label id="lblTotalRecords" Runat="server"></asp:Label>
</asp:Panel>
</form>
</P>
</body>
</HTML>
Og side 2...
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace CodeBank.Google
{
/// <summary>
/// Summary description for GoogleSearch.
/// </summary>
public class GoogleSearch : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox txtSearchText;
protected System.Web.UI.WebControls.Panel pnlResults;
protected System.Web.UI.WebControls.Label lblTotalRecords;
protected System.Web.UI.WebControls.DataList dlResults;
protected System.Web.UI.WebControls.Button btnSearch;
private void Page_Load(object sender, System.EventArgs e)
{
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnSearch_Click(object sender, System.EventArgs e) {
// Create a Google Search object
GoogleSearchService s = new GoogleSearchService();
// If you want to implement this service you MUST get your own key from Google.
// URL:http://www.google.com/apis/
// DO NOT use the key shown below
GoogleSearchResult r = s.doGoogleSearch("sSvM8ta92W4OTNiD1KrxFNM2Rod1wqqf",txtSearchText.Text,
0, 10, false,"", false, "", "", "");
this.pnlResults.Visible = true;
dlResults.DataSource = r.resultElements;
dlResults.DataBind();
this.lblTotalRecords.Text = r.estimatedTotalResultsCount.ToString();
}
}
}
Jeg får fejlen: Could not load type 'CodeBank.Google.GoogleSearch'... Hvordan kan det være??
