C
Chris
Hi,
I have 2 textboxes (txtVal1, txtVal2) in a WebUserControl
(WebCalcUserControl) for which I write public properties :
public int Value1
{
get { return Convert.ToInt32(txtVal1.Text); }
set { txtVal1.Text = Convert.ToString(value); }
}
public int Value2
{
get { return Convert.ToInt32(txtVal2.Text); }
set { txtVal2.Text = Convert.ToString(value); }
}
Then, I host the user control in a WebForm for which I provide a private
datamember in the webform :
private WebCalcUserControl WebCalcUserControl1 = new WebCalcUserControl();
I add a button (btnAdd) and a Label (lblResult) to the WebForm as well.
Button Event-handler :
private void btnAdd_Click(object sender, System.EventArgs e)
{
lblResult.Text = Convert.ToString(
WebCalcUserControl1.Value1 +
WebCalcUserControl1.Value2);
}
I run the webapp ... enter 2 numbers in the texboxes ... press the
Add-button .. and get a run-time error : Input string was not in a correct
format.
When debugging do i notice that both Text-properties of the textboxes (of
the user control) are empty ??? (Although I entered values at run-time)
How come ?
Thanks
Chris
I have 2 textboxes (txtVal1, txtVal2) in a WebUserControl
(WebCalcUserControl) for which I write public properties :
public int Value1
{
get { return Convert.ToInt32(txtVal1.Text); }
set { txtVal1.Text = Convert.ToString(value); }
}
public int Value2
{
get { return Convert.ToInt32(txtVal2.Text); }
set { txtVal2.Text = Convert.ToString(value); }
}
Then, I host the user control in a WebForm for which I provide a private
datamember in the webform :
private WebCalcUserControl WebCalcUserControl1 = new WebCalcUserControl();
I add a button (btnAdd) and a Label (lblResult) to the WebForm as well.
Button Event-handler :
private void btnAdd_Click(object sender, System.EventArgs e)
{
lblResult.Text = Convert.ToString(
WebCalcUserControl1.Value1 +
WebCalcUserControl1.Value2);
}
I run the webapp ... enter 2 numbers in the texboxes ... press the
Add-button .. and get a run-time error : Input string was not in a correct
format.
When debugging do i notice that both Text-properties of the textboxes (of
the user control) are empty ??? (Although I entered values at run-time)
How come ?
Thanks
Chris