There is certain logic to the creation of search boxes in the .NET Framework. Some programmers use custom search boxes while other use Google's default search box. Both of the methods work efficiently and produce a correct result. But here is a different way to create a search box in .NET Framework, using C#.
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
public partial class Search : System.Web.UI.Page
{
SqlConnection con;
SqlDataAdapter adap;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["login"] == null)
{
Response.Redirect("LoginMessage.aspx");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
con = new SqlConnection(ConfigurationManager.ConnectionString[""].ConnectionString);
con.open();
string cmdst = "select UserName, UserMobile, UserEMail from UserRegistration where UserName='" + TextBox1.Text.Trim() + "'";
adap = new SqlDataAdapter(cmdst, con);
DataSet ds = new DataSet();
adap.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
catch (Exception pp)
{
}
}
}
(Through database connectivity and keywords.)