doramail05
asked on
Accessing the public event delegate from user control to page
having assigned the public event and delegate in the user control,
trying to subscribe the method to local aspx page (that uses the user control) to local delegate , then assign the value (from user control) to local aspx page's text box.
unfortunately, having prob calling the sendMsg with _uc.sendMsg.
//_uc.sendMsg += delegate(string message)
// {
// lblUserControlTextBoxValue .Text = message;
// };
ascx
trying to subscribe the method to local aspx page (that uses the user control) to local delegate , then assign the value (from user control) to local aspx page's text box.
unfortunately, having prob calling the sendMsg with _uc.sendMsg.
//_uc.sendMsg += delegate(string message)
// {
// lblUserControlTextBoxValue
// };
protected void Page_Load(object sender, EventArgs e)
{
lbl02.Text = Master.HeaderValue.ToString();
UserControl _uc = (UserControl)Master.FindControl("UC01");
//_uc.sendMsg += delegate(string message)
// {
// lblUserControlTextBoxValue.Text = message;
// };
}
ascx
public event SendMessageDelegate sendMsg;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn01_Click(object sender, EventArgs e)
{
decimal dec01 = Convert.ToDecimal(txt01.Text);
decimal dec02 = Convert.ToDecimal(txt02.Text);
decimal dectotal = dec01 + dec02;
if (sendMsg != null)
{
sendMsg(dectotal.ToString());
}
//lblusercontrol01.Text = dectotal.ToString();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.