Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i've a usercontrol which contains a textbox in it,
now i want to show some value in it but from another .ascx. How can i do that in c#.
Posted

1 solution

You have to Create Event Handler for User control like this

User control code behind

public event EventHandler SaveReport_Click;
C#
protected void BtnSaveReport_Click(object sender, EventArgs e)
       {
           SaveReport_Click(sender, e);
           getReportName = TxtReportName.Text;          

       }


UserControl.ascx
VB
<asp:Button ID="BtnSaveReport" runat="server" Text="Save Report" Width="95px"
                                                   OnClick="BtnSaveReport_Click"/>


base on usercontrol button click fire the normal event to call button click.
Previours we created event handler right.. And we create get and set methord to assign the value for that variable. Call the Global event.

C#
private string getReportName;

       public string GetReportName
       {
           get { return getReportName; }
           set { getReportName = value; }
       }



aspx Page.

After implement the user controls, based up usercontrols id we can get that global event in our aspx page.
ASP.NET
<uc1:reportdownload id="UCISaveReport"  runat="server" xmlns:uc1="#unknown" />


and we create one more event handle to call the methord and we get that value.
C#
UCISaveReport.SaveReport_Click += new EventHandler(BtnSaveReport_Click);


aspx.cs code behind
C#
protected void BtnSaveReport_Click(object sender, EventArgs e)
        {
            SaveReport();
        }
 
Share this answer
 
v3

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