I am following this tutorial to create dynamic search results from an SQL server as a user types. It is telling me to create a .asmx file, which is not a format I have ever worked with before. I now have a .asmx and .asmx.cs file. Here is the code I have thus far :
WebService.asmx.cs :
public class SearchService : WebService
{
[WebMethod]
public searchResult[] Search(string txtSearch)
{
//Declare collection of searchResult
List resultList = new List();
var db = Database.Open("mPlan");
var result = db.Query("SELECT * from Users where Username like '%" + txtSearch + "%'");
try
{
foreach(var record in result)
{
searchResult result = new searchResult();
result.Username = ["Username"].ToString();
resultList.Add(result);
}
return resultList.ToArray();
}
catch
{
return null;
}
}}
WebService.asmx :
<%@ WebService Language="C#" class="WebService" %>
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
[System.Web.Script.Services.ScriptService]
[System.Web.Script.Services.GenerateScriptType(typeof(searchResult))]
public class searchResult
{
public string Title;
public string img;
public string href;
}
Here is my error message, can anyone help me with this please?
Parser Error Message: Could not create type 'WebService.asmx.cs'
It highlights line 1 of WebService.asmx as the source of the error.
The correct class name is "SearchService". You specified a file name.