VB.NET How to get integer from Request -
i want integer url querystring, want protect against strings being entered. example;
http://mydomain.com/index.aspx?page=1 dim ipageid integer = request("page")
i want '1' , save integer variable, page errors out if enter below address;
http://mydomain.com/index.aspx?page=string
i've tried using cint , ctype, brings 'string cannot converted integer' issue. i'm sure there's simple can do, i've been banging head against wall hour , want small thing sorted.
use request.querystring
, int32.parse
convert string "1"
integer
1.
dim ipageid integer = int32.parse(request.querystring("page"))
if ant ensure querystring valid use int32.tryparse
:
dim ipageid integer if int32.tryparse(request.querystring("page"), ipageid) ' valid, ... else ' invalid end if
Comments
Post a Comment