判断网址输入格式以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

 

posted @ 2013-07-30 15:00  Token007  阅读(2279)  评论(0编辑  收藏  举报