【问题标题】:Trying to change a class value from webBrowser c#尝试从 webBrowser c# 更改类值
【发布时间】:2019-04-25 03:17:40
【问题描述】:

尝试从 Windows 窗体 c# 中选中和取消选中 webBrowser 上的一个框。我只知道如何更改 elementbyid 值而不是 elementbyclass 值,如果存在的话...从 html 内部,我可以将类值从“未选中”更改为“已选中”。但我不知道如何从 windows froms 中的 c# webBrowser 做到这一点。对不起,我的英语有限。谢谢。

我尝试过的

webBrowser1.Document.GetElementById("signup-termservice").SetAttribute("unchecked", "checked");

如果我可以将此类的值更改为 unchecked 以选中它会很好...

<span class="unchecked" id="signup-termservice"></span>

通过更改 html 类,它会选中复选框。

【问题讨论】:

    标签: javascript c# html webbrowser-control


    【解决方案1】:

    首先,找到并获取 HTML 元素,更改 className 属性

    HtmlElement htmlElement = webBrowser1.Document.GetElementById("signup-termservice");
    if (htmlElement != null)
     {
      htmlElement.SetAttribute("ClassName", "unchecked");
     }
    

    【讨论】:

      【解决方案2】:

      C# ASP.NET How to modify CSS class via code-behind

      看看这个类似的问题,你必须在你的情况下弄清楚。但我希望你问这样的问题

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-02-07
        • 2011-06-02
        • 2010-09-13
        • 1970-01-01
        • 1970-01-01
        • 2016-07-15
        • 2023-04-04
        • 1970-01-01
        相关资源
        最近更新 更多