Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

asp.net - jquery ui autocomplete needs additional function -


i have such autocomplete code:

$("input#pickupspot").autocomplete({   source: function(request, response){      $.ajax({         url: "ajaxsearch.aspx",         datatype: "jsonp",         data: {            a: "getspots",            c: "updatespotlist",            q: request.term         },         success: function(){            alert("success");         },         error: function (xhr, ajaxoptions, thrownerror){                 alert(xhr.status);                 alert(thrownerror);         }       });   } 

});

when try data firebug shows error: "updatespotlist not defined". need creat function called updatespotlist response server. , success alert never invoked.

why need function? maybe there defined in aspx? is:

string response = "";   string callback = request.querystring["c"];  string action = request.querystring["a"];   string query = request.querystring["q"];    //ensure action parameter set   if(action != null && action.equals("getspots")){         //ensure query parameter set         if (query != null && query.length > 0){             spotlistrequest request = new spotlistrequest             {                 freetext = query,                 language = "sv-se"             };             ienumerable<spot> spots = databridge.getspotlist(null, null, query).orderby(i => i.fullname);              javascriptserializer js = new javascriptserializer();              string json = js.serialize(spots.toarray());              //ensure callback parameter set             if (callback != null && callback.length > 0)             {                 response = string.format("{0}('{1}')", callback, json);             }         }     } 

you can specify url source parameter, instead of data parameter.

http://jqueryui.com/demos/autocomplete/#option-source

the plugin make request server, , should return json array looking this:

[{label: "name"}, {label: "name 2"}]

change javascript code this:

$("input#pickupspot").autocomplete({   source: "ajaxsearch.aspx?a=getspots&c=updatespotlist" }); 

the autocomplete plugin append parameter named term source url, current value of input element, request made to: "ajaxsearch.aspx?a=getspots&c=updatespotlist&term=test" if wrote test in input element.

on server, want change q term.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -