.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Javascript >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

TextSearch With Overlay Screen

Posted By:Mahak Gupta       Posted Date: October 03, 2010    Points: 10    Category: Javascript    URL: http://www.dotnetspark.com  

TextSearch With Overlay Screen
 

I create a code for overlay and TextSeach(ajax)

Follow these Steps:->

Step 1:-> In .aspx page:-
 
First create two TextBox in HTML( txtsearch,txtlname (In my case) )  and a ListBox(ListBox1)


Write the Following Code in Head :

  


    Untitled Page




    


 





and the following Code in Body:-

















    


        

plz click the button to fill the gridview

<%----%>
First Name <%----%>
 
Location
 
<%----%>
gdfggfhfghd
Step 2:- In .cs page:-> Write the following code:- protected void Page_Load(object sender, EventArgs e) { string str1 = ""; if (Request.QueryString["name"] == "") { Response.Clear(); Response.End(); } else if (Request.QueryString["name"] != null) { Response.Clear(); string name = Request.QueryString["name"].ToString(); int len = name.Length; ListBox1.Visible = true; for (int i = 0; i <= len; i++) { string c = name.Substring(i, len); string str = ""; str += c; SqlConnection conn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ToString()); SqlCommand cmd1 = new SqlCommand("select DISTINCT fname from testseach where fname like '" + str + "%'", conn1); conn1.Open(); SqlDataReader dr; if (txtsearch.Value != null) { dr = cmd1.ExecuteReader(); int a = 0; while (dr.Read()) { if (str1 == "") { str1 = dr["fname"].ToString(); } else { str1 += "," + dr["fname"].ToString(); } a = a + 1; } GridView2.DataSource = dr; GridView2.DataBind(); dr.Close(); conn1.Close(); //else //{ // ListBox1.Items.Clear(); //} //str1.Remove(len-1,2); Response.Write(str1); Response.End(); } } } } protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { //txtsearch.Value = ListBox1.SelectedItem.Text; } protected void Submitbttn_Click(object sender, EventArgs e) { SqlConnection conn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ToString()); conn1.Open(); SqlCommand cmd1 = new SqlCommand("select * from testseach where fname='" + txtsearch.Value + "' or lname='" + txtlname.Value + "'", conn1); SqlDataReader dr1; dr1 = cmd1.ExecuteReader(); GridView1.DataSource = dr1; GridView1.DataBind(); conn1.Close(); txtsearch.Value = ""; txtlname.Value = ""; }


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend