Wednesday, 15 July 2015

javascript - Best way to get server-side data to client-side script in usercontrol -



javascript - Best way to get server-side data to client-side script in usercontrol -

i'm starting build usercontrol live on sharepoint 2007 pagelayouts. usercontrol's purpose display map of several locations based on name of page. needs take page name, go query sharepoint list relevant collection of geo coordinates, load them on map. i've never done much client side scripting beyond simple modification of elements , academic jquery ajax calls. i'm trying understand mutual practices passing info around.

i've seen lot of stuff online talking ajax calls page methods, out because user control. alternative looks ajax calls web service. i've built web services before consumption .net clients. this still way set .net web service called scripts? security? if want page or site calling web service , not general public?

in case, i'm not sure service necessary. can retrieve info , set on page during initial request? json serializing coordinate collection in code behind , writing hidden field javascript pick up?

there several ways of passing values usercontrol javascript.

scriptcontrol:

allows include client behavior web control. see links below: creating script controls asp.net: create ajax server controls using scriptcontrol base of operations class asp.net ajax scriptcontrol tutorial

registerstartupscript , registerclientscriptblock:

allows include client side script blocks on page. see links below: working client-side script injecting client-side script asp.net server control

htmlgenericcontrol:

nothing stops creating script tag dinamically , inserting javascript logic innerhtml property. done during initial request.

example:

htmlgenericcontrol script = new htmlgenericcontrol("script"); script.id = "script"; script.attributes.add("type", "text/javascript"); script.innerhtml = "alert('hey');"; //insert script asp:panel panel.controls.add(script);

javascript asp.net ajax json

No comments:

Post a Comment