public GetAttributeValue ( string name, bool def ) : bool | ||
name | string | The name of the attribute to get. May not be null. |
def | bool | The default value to return if not found. |
return | bool |
public bool GetAttributeValue(string name, bool def)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
if (!HasAttributes)
{
return def;
}
HtmlAttribute att = Attributes[name];
if (att == null)
{
return def;
}
try
{
return Convert.ToBoolean(att.Value);
}
catch
{
return def;
}
}
HtmlNode::GetAttributeValue ( string name, int def ) : int | |
HtmlNode::GetAttributeValue ( string name, string def ) : string |
public bool SetValue(HtmlNode n, string value) { if (n is HtmlNode && n.Name == "select") { foreach (HtmlNode o in n.SelectNodes("option")) { o.SetAttributeValue("selected", o.GetAttributeValue("value", "").Equals(value) ? "selected" : ""); } return true; } if (n is HtmlNode && n.Name == "input") { switch (n.GetAttributeValue("type", "")) { case "radio": n.SetAttributeValue("checked", n.GetAttributeValue("value", "").Equals(value) ? "checked" : ""); break; default: n.SetAttributeValue("value", value); break; } n.SetAttributeValue("value", value); return true; } return false; }