本文整理汇总了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();
}
}
}
示例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;
}
示例3: HtmlCheckBox
public HtmlCheckBox(HtmlElement element)
: base(element.Id)
{
// 如果checkbox的有属性是“checked”它将被检查。
string chekced = element.GetAttribute("checked");
Checked = !string.IsNullOrEmpty(chekced);
}
示例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;
}
示例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(" ", "+");
}
}
示例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 ) );
}
示例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;
}
示例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();
}
}
}
示例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;
}
示例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();
}
示例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(' ','>')
};
}
示例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");
//.........这里部分代码省略.........
示例13: NavigateToAsHref
private void NavigateToAsHref(HtmlElement navigateAElem)
{
var href = navigateAElem.GetAttribute("href");
var url = href;
webBrowser1.Navigate(url);
}
示例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;
}
示例15: HtmlPassword
public HtmlPassword(HtmlElement element)
: base(element.Id)
{
Value = element.GetAttribute("value");
}