Simple question, regarding .net syntax more than anything.
I'm a vb6 coder, new to .net and its way of working... anyway, I'm using the follow bit of code. If the Querystring item "ID" is not passed then szPage will be 'Nothing'.
VB Code:
Dim szPage as String = Request.QueryString("ID") If szPage = "12345" Then 'Do This Else 'Do Summat Else End If
If ID is not passed this produces an error ... Now I can sort this by doing;
VB Code:
If Not (Request.QueryString("ID") Is Nothing) Then Dim szPage as String = Request.QueryString("ID") If szPage = "12345" Then 'Do This Else 'Do Summat Else End If Else 'Error End If
I know .NET has some much better ways of working with objects and I am very tuned into vb6 which I find can be a prob when using .net. This code just seems a bit long winded for something thats going to be very common... is there a BETTER/shorter way of writing this code?
Cheers for any replys,
GaZ




Reply With Quote