Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Team,

i have aspx page with more values, i want to pass that values to ascx page, that page will show the values.

so for i search many sites but not able to find correct way, still i'm looking.

can anyone please help me to assist how to pass values in easy way.

Thanks
Renga
Posted

You can do it in two ways.

1. One you can declare some Public properties on user control which you can access on ASPX page.

2. You can add one event in UC which you can pass/bubble up to aspx page with that you can pass data.

See below inside user control

C#
// Delegate declaration
public delegate void mydelegate(string str);

// Event declaration
public event mydelegate btnHandler;


C#
protected void UC1btn1_Click(object sender, EventArgs e)
{  

    // Check if event is null
    if (btnHandler != null)
        btnHandler("");
}


In aspx page

UC11.btnHandler += new UC1.mydelegate(UC1_Click);

C#
public void UC1.mydelegate UC1_Click()
        {

        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900