the jquery work perfectly when I use the snippets in .aspx including this
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
then I wrote following code in my .cs file
protected void Page_Load(object sender, EventArgs e)
{
DataClassesDataContext db = new DataClassesDataContext();
var val = from q in db.ques_tbls select q.qTitle;
db.SubmitChanges();
}
after adding this I changed one line in the script in .aspx like this
var availableTags = <%=val%>;
I ended up with this error.
.
Compiler Error Message: CS0103: The name ‘val’ does not exist in the current context
Source Error:
Line 12: <script type="text/javascript">
Line 13: $(function () {
Line 14: var availableTags = <%=val %>;
Line 15: function split(val) {
Line 16: return val.split(/,\s*/);
You declared val a local variable to your Page_Load method
It must exist at the class level for the aspx page to use it. Create a member or property to store the value.