Firing user control event from parent control

Ask a Question related to ASP.NET Building Controls, Design and Development.

  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. Similar Questions and Discussions

    1. Composite Control - Event not firing in child control
      Hello: I am experiencing an issue where I have a composite control (TestOuter) composed of more composite (TestInner) controls. When I am...
    2. Grid Control ItemData event not firing
      I have a grid control on a page that I copied from another page and modified. For some reason it seem my ItemData event never fires. I even put...
    3. Control added programmatically not firing event
      Hi, I'm loading a usercontrol with image buttons into a panel. When clicking the buttons the click event does not fire. Any suggestions Thanks...
    4. Know in user control page_load if an user control event is going to be fired
      Hi all, i have built a user control that shows a map and let the user zoom in, out, usual stuff. Putting this object in a webform the user can...
    5. Dynamic Control Event Not Firing Help
      In my ASP.NEt codebehind, I declare a public var for a DataGrid. Then in the TextChanged event handler for a TextBox, I create a <div> tag, stuff...
  3. #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

  4. #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

Posting Permissions

  • You may not post new threads
  • You may 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