Cómo establecer una casilla de verificación en & # 8220; marcado & # 8221; usando mshtml?
Pregunta
Puedo hacer la mayoría de las cosas que necesito con mshtml, pero estoy un poco atascado con la forma de configurar un elemento de entrada de casilla de verificación en "marcado". Aquí está la situación ...
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
}
}
¡Gracias de antemano por cualquier ayuda!
Gregg
Solución
HTMLInputElement expone la propiedad Checked como un Booleano
Otros consejos
En JavaScript simple, los elementos de la casilla de verificación tienen una propiedad marcada
. Entonces [en JavaScript simple] podrías escribir:
document.getElementById("myCheckbox").checked = true;
No sé .NET o lo que sea que estés usando allí, pero pueden hacerlo de manera similar.
Steve
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow