asp.net - Pass parameters to a webmethod from querystring -
guys. i'm developing website asp , vb.net 4. i'm using fullcalendar jquery plugin, have trouble: catching parameter querystring webmethod in .asmx. i've tried refer querystring property request.querystring() , doesn't work.
here's webmethod:
<%@ webservice language="vb" class="wbscalendario" %> imports system.web imports system.data imports system.data.sqlclient imports system.web.services imports system.web.services.protocols imports system.web.script.services imports system.collections.generic imports system.configuration.configurationmanager <webservice(namespace:="http://tempuri.org/")> _ <webservicebinding(conformsto:=wsiprofiles.basicprofile1_1)> <scriptservice> _ public class wbscalendario inherits system.web.services.webservice <webmethod()> _ public function listareventos(byval starte string, byval ende string, byval v string) list(of calendarioevento) dim conexaosql new sqlconnection(connectionstrings("praeconnectionstring").connectionstring) dim comandosql sqlcommand = new sqlcommand("splistareventoscalendario", conexaosql) comandosql.commandtype = commandtype.storedprocedure comandosql.parameters.addwithvalue("@bitpendentes", 0) comandosql.parameters.addwithvalue("@agendamentos", "188,135") comandosql.parameters.addwithvalue("@start", fromunixtimespan(starte)) comandosql.parameters.addwithvalue("@end", fromunixtimespan(ende)) comandosql.parameters.addwithvalue("@veiculo", v) dim eventos list(of calendarioevento) = new list(of calendarioevento) try conexaosql.open() dim sdreventos sqldatareader = comandosql.executereader while sdreventos.read dim evento new calendarioevento evento.title = strconv(sdreventos("vchnome").tostring, vbstrconv.propercase) evento.start = tounixtimespan(convert.todatetime(sdreventos("vchdata") + " " + sdreventos("vchhora"))) eventos.add(evento) end while catch ex exception conexaosql.close() end try comandosql.parameters("@bitpendentes").value = 1 try conexaosql.open() dim sdreventos sqldatareader = comandosql.executereader while sdreventos.read dim evento new calendarioevento evento.title = strconv(sdreventos("vchnome").tostring, vbstrconv.propercase) evento.start = tounixtimespan(convert.todatetime(sdreventos("vchdata") + " " + sdreventos("vchhora"))) evento.color = "#6ab0d8" eventos.add(evento) end while catch ex exception conexaosql.close() end try return eventos end function private shared function tounixtimespan(byval d datetime) long dim time new timespan() time = d.touniversaltime().subtract(new datetime(1970, 1, 1, 0, 0, 0)) return ctype(math.truncate(time.totalseconds), int64) end function private shared function fromunixtimespan(byval s string) datetime dim time datetime = new datetime(1970, 1, 1, 0, 0, 0) return time.addseconds(s) end function
end class
can me?
thanks.
the values in query string automatically translated arguments defined on webmethod.
if had webmethod:
<webmethod()> public sub dowork(arg1 integer, arg2 string)
and called url of:
http://domain/webservice.asmx/dowork?arg=2&arg2=hello
those 2 querystring parameters translated 2 arguments arg1 , arg2, referenced normal within dowork() method.
Comments
Post a Comment