Reputation: 8404
What I currently have is this:
if ((string)Session["PlanID"] == null)
{
string PlanID = Request.QueryString["PlanID"];
Session["PlanID"] = PlanID;
}
What I need is something like this:
if ((string)Session["PlanID"] == null) or if ((string)Session["PlanID"] == "")
{
string PlanID = Request.QueryString["PlanID"];
Session["PlanID"] = PlanID;
}
How would I do that?
Upvotes: 0
Views: 399
Reputation: 5953
You can use the String.IsNullOrWhiteSpace Method.
This method also checks for null values
Indicates whether a specified string is null, empty, or consists only of white-space characters.
if (string.IsNullOrWhiteSpace((string)Session["PlanID"]))
{
string PlanID = Request.QueryString["PlanID"];
Session["PlanID"] = PlanID;
}
Upvotes: 1
Reputation: 141
You can use IsNullOrEmpty from string.
if (string.IsNullOrEmpty((string)Session["PlanID"])) {
string PlanID = Request.QueryString["PlanID"];
Session["PlanID"] = PlanID;
}
Upvotes: 3