usercontrol.ascx
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged" AutoPostBack="True" />
</ContentTemplate>
</asp:UpdatePanel>
usercontrol.ascx.cs
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
if (queryText != "")
{
SearchQueryAndSiteSettingsServiceProxy settingsProxy = SPFarm.Local.ServiceProxies.GetValue<SearchQueryAndSiteSettingsServiceProxy>();
SearchServiceApplicationProxy proxy = settingsProxy.ApplicationProxies.GetValue<SearchServiceApplicationProxy>("Search Service Application");
FullTextSqlQuery query = new FullTextSqlQuery(proxy);
query.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default;
//query.QueryText = queryText;
query.QueryText = String.Format(@"SELECT Title FROM SCOPE() WHERE Title Like '"+queryText+"%' AND (""Scope""='SiteTitle')");
query.ResultTypes |= ResultType.RelevantResults;
ResultTableCollection searchResults = query.Execute();
if (searchResults.Exists(ResultType.RelevantResults))
{
ResultTable searchResult = searchResults[ResultType.RelevantResults];
DataTable result = new DataTable();
result.TableName = "Result";
result.Load(searchResult, LoadOption.OverwriteChanges);
FillResultsGrid(result);
}
}
return null;
}
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged" AutoPostBack="True" />
</ContentTemplate>
</asp:UpdatePanel>
usercontrol.ascx.cs
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
if (queryText != "")
{
SearchQueryAndSiteSettingsServiceProxy settingsProxy = SPFarm.Local.ServiceProxies.GetValue<SearchQueryAndSiteSettingsServiceProxy>();
SearchServiceApplicationProxy proxy = settingsProxy.ApplicationProxies.GetValue<SearchServiceApplicationProxy>("Search Service Application");
FullTextSqlQuery query = new FullTextSqlQuery(proxy);
query.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default;
//query.QueryText = queryText;
query.QueryText = String.Format(@"SELECT Title FROM SCOPE() WHERE Title Like '"+queryText+"%' AND (""Scope""='SiteTitle')");
query.ResultTypes |= ResultType.RelevantResults;
ResultTableCollection searchResults = query.Execute();
if (searchResults.Exists(ResultType.RelevantResults))
{
ResultTable searchResult = searchResults[ResultType.RelevantResults];
DataTable result = new DataTable();
result.TableName = "Result";
result.Load(searchResult, LoadOption.OverwriteChanges);
FillResultsGrid(result);
}
}
return null;
}
JavaScript Training | Javascript Courses
ReplyDeleteTypescript Training in Chennai | Node.js Training in Chennai | Backbone.JS Training in Chennai | Angularjs Training in Chennai
HTML5 Online Training | JavaScript Training in Chennai