I want to create a auto populate textbox in asp.net. However I am unable to populate the textbox dynamically. Any help would be very appreciated.
Javascript code
$( function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"Haskell",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
$("#disable").click ( function() {
$( "#tags" ).autocomplete({
disabled: true
});
});
$("#enable").click ( function() {
$( "#tags" ).autocomplete({
disabled: false
});
});
} );
I have tried to populate from asp.net but I am unable to make it work here is what I have tried.
string[] availableTags = new string[]{
"Las Vegas",
"Los Angeles",
"Tampa",
"New York",
"s",
"sss"
};
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
JavaScriptSerializer serializer = new
JavaScriptSerializer();
string jsArray = serializer.Serialize(availableTags);
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "availableTags", jsArray, true);
}
}