Pergunta

Eu posso fazer a maioria das coisas que eu preciso com mshtml, mas estou um pouco preso com como definir um elemento de entrada caixa de seleção para "marcada". Aqui está a situação ...

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
     }
}

Agradecemos antecipadamente por qualquer ajuda!

Gregg

Foi útil?

Solução

HTMLInputElement expõe a propriedade verificado como um boolean

Outras dicas

Em JavaScript simples, elementos de caixa de seleção tem uma propriedade checked. Então [na planície JavaScript] que você pode escrever:

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

Eu não sei .NET ou o que você está usando lá, mas eles podem fazê-lo de uma forma similar.

Steve

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top