當前位置: 首頁>>代碼示例>>C#>>正文


C# HtmlElement.GetAttribute方法代碼示例

本文整理匯總了C#中System.Windows.Forms.HtmlElement.GetAttribute方法的典型用法代碼示例。如果您正苦於以下問題:C# HtmlElement.GetAttribute方法的具體用法?C# HtmlElement.GetAttribute怎麽用?C# HtmlElement.GetAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.HtmlElement的用法示例。


在下文中一共展示了HtmlElement.GetAttribute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AttachContextMenu

        private void AttachContextMenu(HtmlElement he)
        {
            if (he.TagName.Equals(TagNames.BodyTagName))
            {
                if (bodyContextMenu == null)
                {
                    InitializeBodyContextMenu();
                }
            }

            if (he.TagName.Equals(TagNames.AnchorTagName))
            {
                if (!he.GetAttribute("href").Equals(string.Empty))
                {
                    if (linkContextMenu == null)
                    {
                        InitializeLinkContextMenu();
                    }
                }
            }

            if (he.TagName.Equals(TagNames.ImageTagName))
            {
                if (!he.GetAttribute("longdesc").Equals(string.Empty))
                {
                    InitializeEquationContextMenu();
                }
            }
        }
開發者ID:AlexGaidukov,項目名稱:gipertest_streaming,代碼行數:29,代碼來源:HtmlToolContextMenuHelper.cs

示例2: SafeAttribute

		public static string SafeAttribute(HtmlElement htmlNode, string strName)
		{
			if(htmlNode == null) { Debug.Assert(false); return string.Empty; }
			if(string.IsNullOrEmpty(strName)) { Debug.Assert(false); return string.Empty; }

			string strValue = (htmlNode.GetAttribute(strName) ?? string.Empty);

			// http://msdn.microsoft.com/en-us/library/ie/ms536429.aspx
			if((strValue.Length == 0) && strName.Equals("class", StrUtil.CaseIgnoreCmp))
				strValue = (htmlNode.GetAttribute("className") ?? string.Empty);

			return strValue;
		}
開發者ID:dbremner,項目名稱:keepass2,代碼行數:13,代碼來源:XmlUtil.cs

示例3: HtmlCheckBox

 public HtmlCheckBox(HtmlElement element)
     : base(element.Id)
 {
     // 如果checkbox的有屬性是“checked”它將被檢查。
     string chekced = element.GetAttribute("checked");
     Checked = !string.IsNullOrEmpty(chekced);
 }
開發者ID:zealoussnow,項目名稱:OneCode,代碼行數:7,代碼來源:HtmlCheckBox.cs

示例4: GetInputElement

        public static HtmlInputElement GetInputElement(HtmlElement element)
        {
            if (!element.TagName.Equals("input", StringComparison.OrdinalIgnoreCase))
            {
                return null;
            }

            HtmlInputElement input = null;

            string type = element.GetAttribute("type").ToLower();

            switch (type)
            {
                case "checkbox":
                    input = new HtmlCheckBox(element);
                    break;
                case "password":
                    input = new HtmlPassword(element);
                    break;
                case "submit":
                    input = new HtmlSubmit(element);
                    break;
                case "text":
                    input = new HtmlText(element);
                    break;
                default:
                    break;

            }
            return input;
        }
開發者ID:zealoussnow,項目名稱:OneCode,代碼行數:31,代碼來源:HtmlInputElementFactory.cs

示例5: ParaRefer

 /// <summary>
 /// 構造函數
 /// </summary>
 /// <param name="pElement"></param>
 public ParaRefer(HtmlElement pElement)
 {
     if ("option".Equals(pElement.TagName, StringComparison.OrdinalIgnoreCase))
     {
         Name = pElement.InnerText;
         Value = pElement.GetAttribute("value");
     }
     else
     {
         Name = pElement.GetAttribute("value");
         Value = Name;
     }
     if (Value != null)
     {
         Value = Name.Replace(" ", "+");
     }
 }
開發者ID:daywrite,項目名稱:Crawler,代碼行數:21,代碼來源:ParaRefer.cs

示例6: Create

		/// <summary>
		/// 根據 HtmlElement 創建標記對象.
		/// </summary>
		/// <param name="element">用於創建標記對象的 HtmlElement.</param>
		/// <returns>ElementMark 對象.</returns>
		public static ElementMark Create ( HtmlElement element )
		{

			if ( null == element )
				throw new ArgumentNullException ( "element", "HtmlElement 不能為空" );

			return new ElementMark ( element.Id, element.TagName, element.Name, element.GetAttribute ( "class" ), element.GetAttribute ( "type" ), ( element.GetAttribute ( "type" ) == "text" || element.GetAttribute ( "type" ) == "password" ) ? string.Empty : element.GetAttribute ( "value" ), element.GetAttribute ( "href" ), IEBrowser.GetFramePath ( element ) );
		}
開發者ID:cform-dev,項目名稱:zsharedcode,代碼行數:13,代碼來源:ElementMark.cs

示例7: GetLevel

 /// <summary>
 /// kimarja az épület szintjét
 /// egyelőre sajnos a hint-ből
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 private int GetLevel(HtmlElement e)
 {
     string title = e.GetAttribute("title");
     string[] tt = title.Split(' ');
     int level;
     try
     {
         level = int.Parse(tt[tt.Length - 1]);
     }
     catch (Exception)
     {
         level = 0;
     }
     return level;
 }
開發者ID:mrkara,項目名稱:easytravian,代碼行數:21,代碼來源:TravanBaseParse.cs

示例8: AttachHintDialogContextMenu

        private void AttachHintDialogContextMenu(HtmlElement he)
        {
            if (he.TagName.Equals(TagNames.BodyTagName))
            {
                if (bodyContextMenu == null)
                {
                    InitializeHintDialogBodyContextMenu();
                }
            }

            if (he.TagName.Equals(TagNames.ImageTagName))
            {
                if (!he.GetAttribute("longdesc").Equals(string.Empty))
                {
                    InitializeHintDialogEquationContextMenu();
                }
            }
        }
開發者ID:AlexGaidukov,項目名稱:gipertest_streaming,代碼行數:18,代碼來源:HtmlToolContextMenuHelper.cs

示例9: SearchDiv

 private HtmlElement SearchDiv(HtmlElement el)
 {
     if (el == null)
     {
         return null;
     }
     if (el.GetAttribute("className") == "WarningMessage PhaseOut")
     {
         return el;
     }
     HtmlElementCollection elc = el.GetElementsByTagName("div");
     if (elc != null)
     {
         foreach (HtmlElement e in elc)
         {
             HtmlElement r = SearchDiv(e);
             if (r != null)
             {
                 return r;
             }
         }
     }
     return null;
 }
開發者ID:gahadzikwa,項目名稱:GAPP,代碼行數:24,代碼來源:BrowserScriptHideOldBrowserWarning.cs

示例10: TestHmtlEelementValue

 protected string TestHmtlEelementValue(HtmlElement he, string dbtable, string dbcolumn, int index)
 {
     string attribute = he.GetAttribute("value");
     if (string.IsNullOrEmpty(attribute))
     {
         return attribute;
     }
     DataSet dataSource = this.DataFormConntroller.DataSource;
     if (!dataSource.Tables.Contains(dbtable))
     {
         LoggingService.WarnFormatted("Table:{0},Column:{1} 關聯的表沒有找到...", new object[] { dbtable, dbcolumn });
         return attribute;
     }
     DataTable table = dataSource.Tables[dbtable];
     if (!table.Columns.Contains(dbcolumn))
     {
         LoggingService.WarnFormatted("Table:{0},Column:{1} 關聯的表沒有找到相應的列...", new object[] { dbtable, dbcolumn });
         return attribute;
     }
     DataRow row = dataSource.Tables[dbtable].Rows[index];
     DataColumn column = this.dataFormController.DataSource.Tables[dbtable].Columns[dbcolumn];
     System.Type dataType = column.DataType;
     if ((((!dataType.Equals(typeof(int)) && !dataType.Equals(typeof(long))) && (!dataType.Equals(typeof(double)) && !dataType.Equals(typeof(decimal)))) && !dataType.Equals(typeof(float))) && !dataType.Equals(typeof(float)))
     {
         return attribute;
     }
     int decimals = 2;
     if (dataType.Equals(typeof(int)) || dataType.Equals(typeof(long)))
     {
         decimals = 0;
     }
     else
     {
         string str2 = he.GetAttribute("format");
         if (!string.IsNullOrEmpty(str2))
         {
             int num2 = str2.LastIndexOf('.');
             decimals = (num2 >= 0) ? ((str2.Length - num2) - 1) : 0;
         }
     }
     return MathHelper.Round(Convert.ToDouble(attribute), decimals).ToString();
 }
開發者ID:vanloc0301,項目名稱:mychongchong,代碼行數:42,代碼來源:AbstractDataForm.cs

示例11: getElementPositionAndSelector

        private ElementPositionAndSelector getElementPositionAndSelector(HtmlElement elm)
        {
            Size size = elm.ClientRectangle.Size;
            if (size.Width == 0)
                size = elm.ScrollRectangle.Size;
            Point pos = elm.ClientRectangle.Location;

            string sFull = "";
            while (elm != null)
            {
                if (elm.TagName == "HTML")
                    break;

                string cls = elm.GetAttribute("classname");
                string id = elm.GetAttribute("id");

                if (!string.IsNullOrEmpty(id))
                    sFull = "#" + id + " > " + sFull;
                else if (!string.IsNullOrEmpty(cls))
                    sFull = elm.TagName + "." + cls + " > " + sFull;
                else if(elm.OffsetParent!=null)
                {
                    int index = elm.OffsetParent.GetElementsByTagName(elm.TagName).OfType<HtmlElement>().IndexOf(e => e == elm);
                    sFull = elm.TagName + "[" + index + "] > " + sFull;
                }

                pos.X += elm.OffsetRectangle.Left;
                pos.Y += elm.OffsetRectangle.Top;

                elm = elm.OffsetParent;
            }
            return new ElementPositionAndSelector {
                  Position = new Rectangle(pos, size),
                  Selector = sFull.Trim(' ','>')
              };
        }
開發者ID:fizikci,項目名稱:Cinar,代碼行數:36,代碼來源:FormCSSSelector.cs

示例12: timer1_Tick

        private void timer1_Tick(object sender, EventArgs e)
        {
            switch (step)
            {
                case 1:

                    step = 0;
                    toolStep.Text = "Étape : 1";
                    hotmailer.webBrowser1.Navigate("http://google.com");
                    hotmailer.Show();
                    step = 2;

                    break;

                case 2:

                    step = 0;
                    toolStep.Text = "Étape : 2";

                    identity = hotmailer.webBrowser1.Document.GetElementById("identity");

                    /*
                     * Modifications for GAF
                     *
                     */

                    SendKeys.Send("test");
                    ClearCookies();
                    WebBrowserHelper.ClearCache();
                    break;

                    if (identity != null)
                    {
                        // Entre mot de passe
                        identity.Focus();

                        SendKeys.Send("loubna");

                        if (identity.GetAttribute("value") != "loubna")
                        {
                            // La page n'était pas chargée
                            step = 2;
                            return;
                        }

                        // Entre code de campagne.
                        campaignCode = hotmailer.webBrowser1.Document.GetElementById("campaignCode");
                        campaignCode.Focus();

                        SendKeys.SendWait(codeDeCampagne);

                        while (campaignCode.GetAttribute("value") != codeDeCampagne)
                        {
                            campaignCode.Focus();

                            // Problème quelconque: on efface l'input et recommence.
                            while (campaignCode.GetAttribute("value") != "")
                            {
                                SendKeys.SendWait("{BACKSPACE}");
                            }

                            SendKeys.SendWait(codeDeCampagne);
                        }

                        // Clique sur une DIV invisble ayant onclick="next();": simule un "{ENTER}"
                        pressEnter = hotmailer.webBrowser1.Document.GetElementById("pressEnter");
                        pressEnter.InvokeMember("click");

                        step = 3;
                    }
                    else
                    {
                        step = 2;
                    }

                    break;

                case 3:

                    step = 0;
                    toolStep.Text = "Étape : 3";

                    // Collecte le compte Yahoo
                    address = hotmailer.webBrowser1.Document.GetElementById("address");
                    strAddress = address.GetAttribute("value");

                    if (strAddress == "")
                    {
                        // La page n'était pas chargée
                        step = 3;
                        return;
                    }

                    // Collecte le mot de passe
                    password = hotmailer.webBrowser1.Document.GetElementById("password");
                    strPassword = password.GetAttribute("value");

                    // Collecte le récipient
                    recipient = hotmailer.webBrowser1.Document.GetElementById("recipient");
                    strRecipient = recipient.GetAttribute("value");
//.........這裏部分代碼省略.........
開發者ID:blorenz,項目名稱:seocortex,代碼行數:101,代碼來源:Macro.cs

示例13: NavigateToAsHref

        private void NavigateToAsHref(HtmlElement navigateAElem)
        {
            var href = navigateAElem.GetAttribute("href");

            var url = href;
            webBrowser1.Navigate(url);
        }
開發者ID:perragradeen,項目名稱:webbankbudgeter,代碼行數:7,代碼來源:BrowserNavigating.cs

示例14: GetXpathId

 private string GetXpathId(HtmlElement ele)
 {
     string id = ele.GetAttribute("id");
     if (String.IsNullOrEmpty(id) == false)
     {
         HtmlElement tmpEle = ele.Document.GetElementById(id);
         if (ele.Equals(tmpEle)) return id;
     }
     return null;
 }
開發者ID:EricBlack,項目名稱:web-automation,代碼行數:10,代碼來源:Main.cs

示例15: HtmlPassword

 public HtmlPassword(HtmlElement element)
     : base(element.Id)
 {
     Value = element.GetAttribute("value");
 }
開發者ID:zealoussnow,項目名稱:OneCode,代碼行數:5,代碼來源:HtmlPassword.cs


注:本文中的System.Windows.Forms.HtmlElement.GetAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。