Question

Je peux faire la plupart des choses dont j'ai besoin avec mshtml, mais je ne sais pas trop comment définir un élément d'entrée de case à cocher sur "coché". Voici la situation ...

IHTMLElementCollection inputElements = (IHTMLElementCollection)doc.all.tags("input");
foreach (IHTMLElement el in inputElements)
{
    string elementHtml = el.outerHTML;
    string termsOfServiceIdentifier = "id=chkUTOS_ver2";

    //  select the Terms of Service checkbox
    if (elementHtml.Contains(termsOfServiceIdentifier)) 
    {
        HTMLInputElement chkTOS = (HTMLInputElement)el;
        chkTOS.@checked = true;  //  that's the solution. Thanks Wayne.
     }
     else
     {
        //  do nothing - we're not interested in this element
     }
}

Merci d'avance pour toute aide!

Gregg

Était-ce utile?

La solution

HTMLInputElement expose la propriété Checked en tant que Booléen

Autres conseils

En JavaScript, les éléments de case à cocher ont une propriété vérifié . Donc [en JavaScript clair] vous pourriez écrire:

document.getElementById("myCheckbox").checked = true;

Je ne connais pas .NET ou ce que vous utilisez là-bas, mais ils peuvent le faire de la même manière.

Steve

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top