Professional Web Applications Themes

Firing user control event from parent control - ASP.NET Building Controls

Hi, actually you don't need events. all you need is internal or public function exposed by your inner user control(UCSub). you can call that function from events on your hosted user contrl(UC): 1) add function in UCSub : internal void UpdateData(string strData) { this.TextBox1.Text = strData; } 2) add protected decleration of UCSub in UC : protected WebUserControl2 UC2; 3) inside UC page_load load UCSub: UC2 = (WebUserControl2)this.LoadControl("WebUserControl2 .ascx"); this.Controls.Add(UC2); 4) Call UCSub UpdateData method from any event in UC : private void Button1_Click(object sender, System.EventArgs e) { UC2.UpdateData(TextBox1.Text); } HTH Natty Gur[MVP] blog : [url]http://weblogs.asp.net/ngur[/url] Mobile: +972-(0)58-888377 *** Sent ...

  1. #1

    Default Re: Firing user control event from parent control

    Hi,

    actually you don't need events. all you need is internal or public
    function exposed by your inner user control(UCSub). you can call that
    function from events on your hosted user contrl(UC):

    1) add function in UCSub :
    internal void UpdateData(string strData)
    {
    this.TextBox1.Text = strData;
    }

    2) add protected decleration of UCSub in UC :
    protected WebUserControl2 UC2;

    3) inside UC page_load load UCSub:
    UC2 = (WebUserControl2)this.LoadControl("WebUserControl2 .ascx");
    this.Controls.Add(UC2);

    4) Call UCSub UpdateData method from any event in UC :
    private void Button1_Click(object sender, System.EventArgs e)
    {
    UC2.UpdateData(TextBox1.Text);
    }

    HTH



    Natty Gur[MVP]

    blog : [url]http://weblogs.asp.net/ngur[/url]
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  2. #2

    Default Re: Firing user control event from parent control

    You can raise an event in an ASP.NET page and capture or handle the event in one or more web user controls.

    The following blog entry should help.

    http://asp-net-elephant.blogspot.com/2011/02/capture-page-event-in-web-user-control.html
    davidgrover is offline Junior Member
    Join Date
    Feb 2011
    Posts
    2

  3. #3

    Default Re: Firing user control event from parent control

    You can raise an event in an ASP.NET page and capture or handle the event in one or more web user controls.

    The following blog entry should help.

    asp-net-elephant.blogspot.com/2011/02/capture-page-event-in-web-user-control.html
    davidgrover is offline Junior Member
    Join Date
    Feb 2011
    Posts
    2

Similar Threads

  1. Composite Control - Event not firing in child control
    By Chris Simmons in forum ASP.NET Building Controls
    Replies: 3
    Last Post: October 28th, 09:45 PM
  2. Grid Control ItemData event not firing
    By HandA in forum ASP.NET Data Grid Control
    Replies: 5
    Last Post: May 13th, 07:30 PM
  3. Control added programmatically not firing event
    By Troy in forum ASP.NET Building Controls
    Replies: 3
    Last Post: March 1st, 08:00 PM
  4. Replies: 5
    Last Post: February 24th, 02:07 PM
  5. Dynamic Control Event Not Firing Help
    By SteveC in forum ASP.NET General
    Replies: 0
    Last Post: August 4th, 08:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139