I create a code for overlay and TextSeach(ajax)
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 :
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script
language="JavaScript"
type="text/javascript">
var
xmlHttp;
var
arr;
function
showHint()
{
document.getElementById("ListBox1").style.display='';
xmlHttp=GetXmlHttpObject()
var url="Default2.aspx";
url=url+"?name="+document.getElementById('txtsearch').value;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
return false;
}
function
stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
var str;
str =
xmlHttp.responseText;
if(str=="")
{
document.getElementById("ListBox1").style.display='none';
}
else
{
arr=str.split(",");
var i;
for(i=0;i<arr.length;i++)
{
// dd2= document.getElementById("ListBox1");
//
// var theOption = new Option;
// theOption.text = arr[i];
// theOption.value = arr[i];
// dd2.options[i] = theOption;
document.getElementById("ListBox1").value=arr[i];
//document.getElementById('txtsearch').value=arr[i];
}
} }
}
function
GetXmlHttpObject()
{
var objXMLHttp=null;
if (window.XMLHttpRequest)
{
objXMLHttp=new
XMLHttpRequest();
}
else if (window.ActiveXObject)
{
objXMLHttp=new
ActiveXObject("Microsoft.XMLHTTP");
}
return objXMLHttp;
}
function close()
{
document.getElementById('light').style.display='none';
document.getElementById('fade').style.display='none';
}
function dis()
{
document.getElementById("txtsearch").value=document.getElementById("ListBox1").value;
document.getElementById("ListBox1").style.display='none';
}
//window.onload
= fillDropDown();
</script>
<style
type="text/css">
.black_show{
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index:1001;
-moz-opacity: 0.8;
opacity:.90;
filter: alpha(opacity=80);
}
.white_show {
display: none;
position: absolute;
top: 25%;
left: 25%;
width: 50%;
height: 50%;
padding: 16px;
-webkit-border-radius:20px;
border: 16px
solid orange;
background-color: white;
z-index:1002;
overflow: auto;
}
.txtname
{
border: 5px
solid orange;
}
</style>
</head>
And the following Code in Body:-
<body>
<form id="form1" runat="server">
<div >
<p>
plz click the button to fill the gridview <input id="Button1" type="button" value="Search" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'" /></p>
<div id="light" class="white_show" style="width: 47%; left: 25%; top: 25%; height46%;">
<table style="width: 100%; height: 68px">
<tr>
<td style="width: 126px; height: 32px">
</td>
<td style="width: 126px; height: 32px">
</td>
<td style="width: 146px; height: 32px">
</td>
<td style="width: 146px; height: 32px">
</td>
<td style="width: 100px; height: 32px; text-align: right" valign="top">
<%--<asp:ImageButton ID="ImageButton1" Height="20px" ImageUrl="~/close_icon.gif"
OnClientClick="close()" />--%>
<img id="Img1" src="close_icon.gif" runat="server" onclick= "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'"/>
</td>
</tr>
<tr>
<td style="width: 126px; height: 2px; text-align: center">
</td>
<td style="width: 126px; height: 2px; text-align: center">
</td>
<td style="width: 146px; height: 2px">
</td>
<td style="width: 146px; height: 2px">
</td>
<td style="width: 100px; height: 2px">
</td>
</tr>
<tr>
<td style="width: 126px; height: 2px; text-align: center">
</td>
<td style="width: 126px; height: 2px; text-align: center">
</td>
<td style="width: 146px; height: 2px">
</td>
<td style="width: 146px; height: 2px">
</td>
<td style="width: 100px; height: 2px">
</td>
</tr>
<tr>
<td style="width: 126px; height: 2px; text-align: center">
</td>
<td style="width: 126px; height: 2px; text-align: center">
</td>
<td style="width: 146px; height: 2px">
</td>
<td style="width: 146px; height: 2px">
</td>
<td style="width: 100px; height: 2px">
</td>
</tr>
<tr>
<td style="width: 126px; height: 2px; text-align: center">
</td>
<td style="width: 126px; height: 2px; text-align: center">
</td>
<td style="width: 146px; height: 2px">
</td>
<td style="width: 146px; height: 2px">
</td>
<td style="width: 100px; height: 2px">
</td>
</tr>
<tr>
<td style="width: 126px; height: 16px; text-align: center;" valign="top">
<strong style="color: orange">First Name</strong></td>
<td style="width: 126px; height: 16px; text-align: center" valign="top">
</td>
<td style="width: 146px; height: 16px" valign="top"><input id="txtsearch" onkeyup="showHint()" onblur="dis()" runat="server" type="text" style="width: 215px" />
<input type="text" id="ListBox1" runat="server" style="display: none; width: 214px;" onclick="dis()" />

Mukesh Kumar TiwariPosted Sep 12, 2013, 8:05 AM
Mahak jee..A very nice demo,with gud explanations .keep it up..thanks