Pankaj Kumar
Pankaj Kumar

Reputation: 105

How add css in .ashx.cs code behind in asp.net

I want to add css class in .ashx page but .aspx Ui page show as string. How to add css in .ashx code behinde page.

I want (Cook) text show in red.

Issue:

enter image description here

     try
            {
    for (int i = 0; i < dsSeaech.Tables[0].Rows.Count; i++)
                {
                    var myString = new StringBuilder();
                    myString.Append("<span style=\"color:red\">(Cook)</span>");                 
                    lstRecipeName.Add(dsSeaech.Tables[0].Rows[i]["RecipeName"].ToString());
                    if (Convert.ToInt32(dsSeaech.Tables[0].Rows[i]["UserType"]) == AppConstant.chefuser)
                    {
                        lstChefName.Add(dsSeaech.Tables[0].Rows[i]["FullName"].ToString() + "(" + "Chef" + ")");
                    }
                    else if (Convert.ToInt32(dsSeaech.Tables[0].Rows[i]["UserType"]) == AppConstant.cook)
                    {
                        lstChefName.Add(dsSeaech.Tables[0].Rows[i]["FullName"].ToString() + myString);
                    }
                }
                
                JavaScriptSerializer js = new JavaScriptSerializer();
                context.Response.Write(js.Serialize(lstRecipeName));
                }
                 catch (Exception ex)
            {
                throw ex;
            }

Upvotes: 0

Views: 205

Answers (1)

Nitin S
Nitin S

Reputation: 7601

You can use the _renderItem event of the autocomplete.

$.ui.autocomplete.prototype._renderItem = function(ul, item) {
  return $("<li></li>")
    .data("item.autocomplete", item)
    .append('<a>'+item.label+'</a>')
    .appendTo( ul );
};

here's fiddle for you: https://jsfiddle.net/192m0uyc/9/

Upvotes: 1

Related Questions