john55
  •  john55
  • 53% (Neutral)
  • YAF Forumling Topic Starter
2013-12-04T23:51:08Z
Hi there,

Running YAF 2.0 on .NET 4.0.

I'm trying to run a YAF search outside of a regular YAF page (inheriting from System.Web.UI.Page). Search runs okay but line where search results get converted to an array is giving a syntax error:

'search_results' does not contain a definition for 'Get' and the best extension method overload 'YAF.Types.Interfaces.IServiceLocatorExtensions.Get<TService>(YAF.Types.Interfaces.IHaveServiceLocator)' has some invalid arguments

any ideas?
Thanks


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;

using YAF.Core.Data;
using YAF.Core.Extensions;
using YAF.Core.Services;
using YAF.Types.Extensions;
using YAF.Types.Interfaces.Data;
using nStuff.UpdateControls;
using YAF.Classes;
using YAF.Classes.Data;
using YAF.Core;
using YAF.Types;
using YAF.Types.Constants;
using YAF.Types.Interfaces;
using YAF.Utilities;
using YAF.Utils;

using System.Collections.Generic;
using System.Runtime.CompilerServices;

using System.Linq;
using System.Text.RegularExpressions;


public partial class search_results : System.Web.UI.Page
{
private void searchBindData(string searchString)
{
var sw = (SearchWhatFlags)Enum.Parse(typeof(SearchWhatFlags), "2"Wink;
var sfw = (SearchWhatFlags)Enum.Parse(typeof(SearchWhatFlags), "2"Wink;
int forumId = 0;

var context = new CompleteSearchContext(
searchString,
"",
sfw,
sw,
3,
1,
100, false, true,
forumId);

//following line gives syntax error
var searchResults = this.Get<ISearch>().Execute(context).ToArray();
Sponsor
tha_watcha
2013-12-05T03:22:56Z
Change the line to....

var searchResults = YafContext.Current.Get<ISearch>().Execute(context).ToArray();

UserPostedImage
john55
  •  john55
  • 53% (Neutral)
  • YAF Forumling Topic Starter
2013-12-05T20:25:31Z
Cool. Thanks. One more question...

In \YetAnotherForum.NET\pages\search.ascx there is

<%# HtmlEncode(Container.DataItem.ToType<SearchResult>().Topic) %>

which I changed to following to run in my page inheriting from System.Web.UI.Page
<%# Server.HtmlEncode(YAF.Types.Extensions.ObjectExtensions.ToType<YAF.Types.Models.SearchResult>(Container.DataItem).Topic) %>

This works fine for Topic, TopicId, etc however .Message doesn't display the message it returns a 0-length string.

How do I display the message in the YAF search results on a page inheriting from System.Web.UI.Page?

Thanks!

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved