pedram

pedram

  • NA
  • 13
  • 12.5k

Changing value of control defined in HTML file

Apr 4 2013 1:20 AM
I've been trying to change the value of a checkbox control defined in an html file,this html file is shown in a webbrowser control and the webbrowser itself is defined as a user control in C#
I am willing to set the value of the checkbox control  (defined  in the html file and user control) from the form that contains my usercontrol
The related code in user control:
        public bool _checkBoxProperty
        {
            set
            {
                if (webBrowser1.Document != null && webBrowser1.Document.GetElementById("Checkbox1") != null)
                {
                    bool s = false;
                    string chpro = webBrowser1.Document.GetElementById("Checkbox1").GetAttribute("checked").ToString();
                    if (chpro == "false")
                        s = false;
                    s = value;
                    webBrowser1.Document.GetElementById("Checkbox1").SetAttribute("checked"value.ToString());
                }
            }
            get
            {
                if (webBrowser1.Document != null && webBrowser1.Document.GetElementById("Checkbox1") != null)
                {
                    {
                        string bls = webBrowser1.Document.GetElementById("Checkbox1").GetAttribute("checked");
                            return Convert.ToBoolean(bls);
                    }
                }
                else
                    return false;
            }
        }

this piece of code brings the checkbox property in my form and I can set its value,but when I run the program it resets itself to null,
I've been working on this piece of code for days and I fully appreciate some help :)


Answers (1)