判断网址输入格式以http://开头的
#region 方法一 判断网址输入格式 if (txtUrl.Text .Length >=7 && txtUrl.Text.Substring(0, 7) == "http://") { labUrl.Visible = false ; } else { labUrl.Visible = true; labUrl.Text = "格式为:http://..."; } if (txtUrlForLogo.Text .Length >=7 && txtUrlForLogo.Text.Substring(0, 7) == "http://") { labUrlLogo.Visible = false; } else { labUrlLogo.Visible = true; labUrlLogo.Text = "格式为:http://..."; } #endregion #region 方法二 判断网址输入格式 if (txtUrl.Text.StartsWith("http://"))// .Substring (0,7) != "http://") { labUrl.Visible = false; } else { labUrl.Visible = true; labUrl.Text = "格式为:http://..."; } if (txtUrlForLogo.Text.StartsWith("http://")) { labUrlLogo.Visible = false; } else { labUrlLogo.Visible = true; labUrlLogo.Text = "格式为:http://..."; } #endregion