I want the AutoComplete image and username to be clickable, so that when i click on the image or username it will redirect to item page
and display the item image and username.
Somthing like this
<a class="" href='<%#getUserHREF1(Container.DataItem)%>' > </a>
code to rediect
~/ItemPage.aspx?Id=" + Id
AutoComplete code
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> SearchEmployees(string prefixText, int count)
{
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager
.ConnectionStrings["Connection"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select Name,UserName,ImageName from User3 where " + "UserName like @SearchText + '%'";
cmd.Parameters.AddWithValue("@SearchText", prefixText);
cmd.Connection = conn;
conn.Open();
List<string> Searchusernames = new List<string>();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
Searchusernames.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(string.Format("{0} {1}", sdr["Name"], sdr["UserName"]), sdr["ImageName"].ToString()));
}
}
conn.Close();
return Searchusernames;
}
}
}
Script
<script type = "text/javascript">
function usernames_Populated(sender, e) {
var Searchusernames = sender.get_completionList().childNodes;
for (var i = 0; i < Searchusernames.length; i++) {
var div = document.createElement("DIV");
div.innerHTML = "<img style = 'height:50px;width:50px; margin-left:6px; margin-bottom:6px;' class= ' img-rounded dropdown messages-menu' src = 'PROFILEPHOTOS/"
+ Searchusernames[i]._value + "' />";
Searchusernames[i].appendChild(div);
}
}
function OnEmployeeSelected(source, eventArgs) {
var idx = source._selectIndex;
var Searchusernames = source.get_completionList().childNodes;
var value = Searchusernames[idx]._value;
var text = Searchusernames[idx].firstChild.nodeValue;
source.get_element().value = text;
}
</script>