Properly process user input or QueryStrings as int
Posted on: Thu Aug 20 11:29:37 -0700 2009. Updated on: Thu Aug 20 11:30:11 -0700 2009.
Category: DotNet
Category: DotNet
Quick code to process incoming querystrings or other user input, ie textboxes from a string to an int.
int messageId;
if (int.TryParse(Request.QueryString["messageId"], out messageId) == false)
{
messageId = -1; // default value for messageId, ie to create a new item.
}