您的位置:首页 > 理论基础 > 计算机网络

判断地址url是以http://开头的

2013-07-30 14:48 274 查看
 #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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: