Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7728381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:42:11+00:00 2026-06-01T05:42:11+00:00

i have a single textbox named Keywords. User can enter multiple strings for search.

  • 0

i have a single textbox named Keywords.
User can enter multiple strings for search.
How this is possible in mvc3?
I am using nhibernate as ORM.
Can i create criteria for this?

Edited Scenario

I have partial view to search job based on following values:

  • Keywords(multiple strings), Industry(cascading dropdown with functional area )//working well ,FunctionalArea//working well
    Loaction(multiple locations), Experience//working well

In Controller i am retrieving these values from form collection.
What datatype should i use for keywords and location (string or string[] )?

   public ActionResult SearchResult(FormCollection formCollection)
            {
    IList<Jobs> JobsSearchResultList = new List<Jobs>();
                //string[] keywords = null;            
                string location = null;
                int? industry = 0;
                int? functionaArea = 0;
                int? experience = 0;
                string keywords = null;

                if (formCollection["txtKeyword"] != "")
                {
                    keywords = formCollection["txtKeyword"];
                }
                //if (formCollection["txtKeyword"] != "")
                //{
                //    keywordAry = formCollection["txtKeyword"].Split(' ');
                //    foreach (string keyword in keywordAry)
                //    {
                //        string value = keyword;

                //    }                
                //}
......retrieving other values from formcollection
....

    //Now passing these values to Service method where i have criteria for job search
JobsSearchResultList = oEasyJobsService.GetJobsOnSearchExists(keywords,industry,functionaArea,location,experience);
        return View(JobsSearchResultList);
    }

In Services i have done like:

public IList<EASYJobs> GetJobsOnSearchExists(string keywords, int? industryId, int? functionalAreaId, string location, int? experience)
{
IList<JobLocation> locationlist = new List<JobLocation>();
IList<Jobs> JobsList = null;
var disjunction = Expression.Disjunction();
ICriteria query = session.CreateCriteria(typeof(Jobs), "EJobs");
if (keywords != null)
        {

        foreach (string keyword in keywords)
        {
        string pattern = String.Format("%{0}%", keyword);
        disjunction
       .Add(Restrictions.InsensitiveLike("Jobs.keywords", pattern,MatchMode.Anywhere))
       .Add(Restrictions.InsensitiveLike("YJobs.PostTitle",pattern,MatchMode.Anywhere));
        }
       query.Add(disjunction)
            .Add(Expression.Eq("EASYJobs.Industry.IndustryId", industryId))
            .Add(Expression.Eq("Jobs.FunctionalArea.FunctionalAreaId", functionalAreaId))
            .Add(Expression.Eq("Jobs.RequiredExperience", experience)));
       }
else
{..
}
JobsList = criteria.List<Jobs>();
}

Problems i am facing are:

  1. In controller if i use string[],then Split(‘,’) does not split the string with specified separator.It passes string as it is to Service.

2.In services i am trying to replace string with %{0}% ,strings with spaces are replaced/concat() here with given delimeter.
But the problem here is It always return the whole job list means not giving the required output.
Pleas help …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:42:12+00:00Added an answer on June 1, 2026 at 5:42 am

    Multiple keywords with special characters or extra spaces are replaced with single space with Regex expressions.
    And then keywords are separated with Split(“”).
    Its working as required….

    if (!string.IsNullOrEmpty(keywords))
                    {
                        keywords = keywords.Trim();
                        keywords = System.Text.RegularExpressions.Regex.Replace(keywords, @"[^0-9a-zA-Z\._\s]", " ");
                        keywords = System.Text.RegularExpressions.Regex.Replace(keywords, @"[\s]+", " "); 
    
                        if (keywords.IndexOf(" ") > 0)
                        {
                            string[] arr = keywords.Split(" ".ToCharArray());
                            for (int i = 0; i < arr.Length; i++)
                            {
                                if (!string.IsNullOrEmpty(arr[i]))
                                {
                                    criteria.Add(Restrictions.Disjunction()
                                     .Add(Expression.Like("EASYJobs.keywords", arr[i], MatchMode.Anywhere)));
                                }
                            }
                        }
                        else
                        {
                            criteria.Add(Restrictions.Disjunction()                      
                                 .Add(Expression.Like("EASYJobs.keywords", keywords, MatchMode.Anywhere)));
                        }
    
                    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I have is a single textbox. If the user hits the maxlength of
I am creating a user form. In this I have textbox and a lot
We have a single SVN repository with multiple related projects. Like so... \repo \Project1
I have a single xml document (data.xml), which I display as HTML using an
I have to use a single text box to use for search by order
I have a custom WPF control which consist of single TextBox <UserControl HorizontalAlignment=Left x:Class=WPFDiagramDesignerControl.Components.UcWBSBlock
I have this function which evaluates the contents of a textbox (or combobox or
I have a View that has a single TextBox and a couple Button s
im doing a search page where i have to search multiple fields with a
Ok, using SQL Server 2008. On my web page I have a textbox with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.