lundi 1 avril 2019

Else statement still firing when IF is true?

I'm currently trying to amend a string depending on an iFrame parameter.

The issue is, when ?iframe is in my URL, both statements fire?

Relatively new to C#, so I apologise if it's something silly.

Simplified version

           //Check iFrame Param
            else
            {
                if (activepage.Contains("?iframe"))
                {
                  example = "Hello IF";
                }
                else
                example = "Hello ELSE";
            }

           test.Text = example;

Actual version

            //Check iFrame Param
            else
            {
                if (activepage.Contains("?iframe"))
                {
                    t = "<div class=\"col-md-4 col-12 mb-3\"><div class=\"card h-100\">";
                    t += "<div class=\"card-body text-center\"><p class=\"card-text\"><strong>" + calName + "</strong><br> " + title + "</p>";
                    t += "<a class=\"btn btn-primary btn-block\" href=\"" + ConfigurationManager.AppSettings["rootURL"] + "booking/b/" + companyID + "/" + cname.ToLower().Replace(" ", "-") + "/" + ID + "/" + calName.ToLower().Replace(" ", "-") + "?iframe\">Book</a></div></div> </div>";
                }
                else
                t = "<div class=\"col-md-4 col-12 mb-3\"><div class=\"card h-100\">";
                t += "<div class=\"card-body text-center\"><p class=\"card-text\"><strong>" + calName + "</strong><br> " + title + "</p>";
                t += "<a class=\"btn btn-primary btn-block\" href=\"" + ConfigurationManager.AppSettings["rootURL"] + "booking/b/" + companyID + "/" + cname.ToLower().Replace(" ", "-") + "/" + ID + "/" + calName.ToLower().Replace(" ", "-") + "\">Book</a></div></div> </div>";
            }

Aucun commentaire:

Enregistrer un commentaire