Link to home
Start Free TrialLog in
Avatar of doramail05
doramail05Flag for Malaysia

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;

            // };


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;

            // };
        }

Open in new window


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();
        }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of doramail05
doramail05
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial