|
-
Jun 18th, 2004, 10:26 AM
#1
Thread Starter
Fanatic Member
blank session variables return
I have a couple of session string variables.
In some cases they will be empty strings and I want them to return an empty string but they return (non breaking space). Is there some quick way, may be a built in function to convert the to and empty string (without an if statement)
-
Jun 18th, 2004, 02:08 PM
#2
Addicted Member
You didn't say what you were programming in. I'll assume VB.Net:
Code:
Dim regEx, str1 ' Create variables.
sessionStr1 = "& nbsp;"
Set regEx = New RegExp ' Create regular expression.
regEx.Pattern = "& nbsp;" ' Set pattern.
regEx.IgnoreCase = True ' Make case insensitive.
'Once the above is set up, you should be able to do the following repeatedly
ReplaceTest = regEx.Replace(sessionStr1, "") ' Make replacement.
The above uses regular expressions which some might argue is overkill. Perhaps, but if you don't know about regular expressions, and you want to gain a competitive edge, learning about them now will definitely help. In a nutshell, regular expressions let you do wildcard matching of strings in wild ways.
HTH,
cudabean
-
Jun 21st, 2004, 04:24 PM
#3
I wonder how many charact
I'm more curious to know why or how your strings are returning  ?
Any session variables I use as strings I always test against String.Empty on the code behind:
VB Code:
If me.Session.Item(0) = String.Empty ...
-
Jun 22nd, 2004, 03:07 AM
#4
Thread Starter
Fanatic Member
After looking back at my code I found out why it was happening.
I am setting the value of the session variable with the value in a datagrid cell. As the database field is null it is defaulting to at bind time.
I have however made a note of string.empty and now use that, thanks nemaroller.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|