javascript - Using a value from a dropdown list in a handler -


i use if can spare time. trying access value of dropdownlist (dropdownlist1) on master page content page , use variable in hanlder in .ashx code page. test trying display varialble in message box. ideas appreciated.

content page (dropdownlist on master page)

$(document).ready(function $("#dropdownlist1").change(function () {             location.reload;               alert($(this).val());             strtrail = $(this).val();             alert(strtrail);          }); 

handler

case "searchbylocation"             dim firsttime integer = 0             dim latitude string = "42.9901009" 'context.request("latitude")             dim longitude string = "-81.146698" 'context.request("longitude")             'dim fromdate string = context.request("#dropdownlist1").val               dim strtrail string = context.request("#dropdownlist1")             msgbox("now")             msgbox(strtrail)             'strtrail = context.request("strtrail")             if firsttime < 1                 strtrail = "lookout"             end if               dim objcbl new jparkinsonlookup.jplookup              dim objds system.data.dataset = objcbl.searchbytrail(strtrail, latitude, longitude, 10)              'result = "{""locations"":[{""id"":""1"",""latitude"":""28.537"",""longitude"":""-81.380""}]}"              result = "{""locations"":["             each dr system.data.datarow in objds.tables(0).rows                  result += "{""id"":""" & dr("id").tostring() & """,""latitude"":""" & dr("latitude").tostring() & """,""longitude"":""" & dr("longitude").tostring() & """},"             next              result = result.substring(0, result.lastindexof(","))              result += "]}"             firsttime = 1           case "searchbydescription"       end select       'second command     'third command      context.response.write(result)    end sub 

firt of avoid msgbox coz throw in exception (not valid in aspnet page contest)

second 1 when go through document.ready have make ajax request per code return json object need parse within javascript object ad read value it.

   $.ajax( { type: "get", url: url, data: qry, success: function (msg) {     lat = msg.locations[0].latitude;     lng = msg.locations[0].longitude;    alert(lat +' ' + lat); }, error: function (msg) {     $("#coor").html("errore durante l'elaborazione"); } }); 

another important stuff use directive set response:

        context.response.contenttype = "application/json"; 

take care check via chrome or firefox response , call via network call able have more info. code not test use working code @ end , make changes let idea.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -