Validate QueryString varialbe in correct way.

Posted by Virendradugar under VB.NET category on | Views : 2723
Use below given code to validate querystring variables.

Private Function ValidateQueryString() As Boolean
If Request.QueryString("name") <> Nothing Then
If Request.QueryString("name").ToString() <> String.Empty Then
Return True
End If
Return False
End If
End Function

This code first checks for existence of querystring variable "name". If it exists, then it's check for it's value. As sometimes it's quite possible that the querystring variable is present but with no value. Something like this :

Over here no value is assigned to name variable. So we need to check it's value also.

Virendra Dugar

Comments or Responses

Login to post response