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:
C#
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 :)
pedram11 pointsPosted Apr 3, 2013, 11:44 PM EDT
here is the code in case someone needs it
usercontrol:
public delegate void ThisLoadEventHandler(object sender, EventArgs e); public event ThisLoadEventHandler ThisLoad; void OnThisLoad() { if (ThisLoad != null) ThisLoad(this, new EventArgs()); } private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { OnThisLoad(); } public webctrl1() { InitializeComponent(); OnThisLoad(); } In the main form: private void defultstart() { webctrl11._radioBoxProperty = "false"; webctrl11._checkBoxProperty = false; webctrl11._textageProperty = "Age"; webctrl11._textnameProperty= "Name"; webctrl11._listBoxProperty = "<SELECT id=Select1 name=drop1> <OPTION value=0></OPTION> <OPTION value=1>item 3</OPTION> <OPTION value=2>item 4</OPTION></SELECT>"; } private void webctrl11_ThisLoad(object sender, EventArgs e) { defultstart(); }