Referencing a panel on a webform from an usercontrol

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

  1. #1

    Default Referencing a panel on a webform from an usercontrol

    My question is whether it's possible to change the
    properties of a panel, that resides on the webform
    containing the usercontrol, in the usercontrol itself.

    Like this:

    <form>
    <asp:panel visibility=false .... </asp panel>
    <user:control> //a function here turns the visibilty to
    true </user:control>
    </form>

    Greetz,

    Lokhan Wong
    [email]Lokhan_wong@hotmail.com[/email]

    //cogito ergo sum

    Lokhan Wong Guest

  2. Similar Questions and Discussions

    1. referencing and anchor from within a usercontrol (ascx)
      Hi, I am trying to reference an anchor in a user control with a url. This worked in 1.1 but no longer works in 2.0. The ascx control is...
    2. Event not firing in usercontrol inside usercontrol
      I'm stumped on this problem. I've created a user control that dynamically creates 5 linkbuttons in the CreateChildControls method. Each of these...
    3. Including WebForm Image Control in a Webform Table Control
      What is the code for including an image control in a Table control of a WebForm ???? regards
    4. Referencing subcontrols within UserControl
      Does anyone know how to reference a subcontrol of a UserControl within client-side script. For example, if I have a TextBox as one of the elements...
    5. Use LoadControl to load a usercontrol but the webcontrol in the usercontrol can not AutoPostBack
      a uscontrol test.ascx have a dropdownlist web control the dropdownlist's AutoPostBack property is set "true" but when i use...
  3. #2

    Default Re: Referencing a panel on a webform from an usercontrol

    Lokhan Wong wrote:
    >My question is whether it's possible to change the
    >properties of a panel, that resides on the webform
    >containing the usercontrol, in the usercontrol itself.
    >
    >Like this:
    >
    ><form>
    ><asp:panel visibility=false .... </asp panel>
    ><user:control> //a function here turns the visibilty to
    >true </user:control>
    ></form>
    >
    >Greetz,
    >
    >Lokhan Wong
    >Lokhan_wong@hotmail.com
    >
    >//cogito ergo sum
    >
    >
    This is possible:

    In the usercontrol code behind I have:

    private void Page_Load(object sender, System.EventArgs e)
    {
    // Put user code to initialize the page here
    if(Page.IsPostBack)
    {
    // Find the control
    System.Web.UI.WebControls.Panel ctrl =
    (System.Web.UI.WebControls.Panel) Page.FindControl("MyPanel");

    // Make it visible
    ctrl.Visible = true;

    // Abd Add some text
    Label lbl = new Label();
    lbl.Text = " Now you see me!";
    ctrl.Controls.Add(lbl);
    }
    }

    On the aspx page containing the usercontrol:

    <form id="Form1" method="post" runat="server">
    <asp:panel id="MyPanel" visible="False" runat="server">Hello</asp:panel>
    <kk:MyControl id="MyControl" runat="server" />
    </form>

    From a design perspective I'd be wary of doing this because you are
    creating a dependancy in the containing page and introducing some tight
    coupling that will affect the user control's re-use in other pages..

    HTH
    Kev


    Kevin Kenny Guest

  4. #3

    Default Re: Referencing a panel on a webform from an usercontrol

    It worked. Thanks for the info.

    The reason why I used it this way is because I wanted to
    make a registering page made of several steps. Putting
    every step in a seperate page would be unwise. Also
    putting every step in a seperate panel on the page would
    make the page unmanageable. So by putting every step in
    its own usercontrol I can manage the code more easily.
    >-----Original Message-----
    >Lokhan Wong wrote:
    >
    >>My question is whether it's possible to change the
    >>properties of a panel, that resides on the webform
    >>containing the usercontrol, in the usercontrol itself.
    >>
    >>Like this:
    >>
    >><form>
    >><asp:panel visibility=false .... </asp panel>
    >><user:control> //a function here turns the visibilty to
    >>true </user:control>
    >></form>
    >>
    >>Greetz,
    >>
    >>Lokhan Wong
    >>Lokhan_wong@hotmail.com
    >>
    >>//cogito ergo sum
    >>
    >>
    >This is possible:
    >
    >In the usercontrol code behind I have:
    >
    >private void Page_Load(object sender, System.EventArgs e)
    >{
    > // Put user code to initialize the page here
    > if(Page.IsPostBack)
    > {
    > // Find the control
    > System.Web.UI.WebControls.Panel ctrl =
    >(System.Web.UI.WebControls.Panel) Page.FindControl
    ("MyPanel");
    >
    > // Make it visible
    > ctrl.Visible = true;
    >
    > // Abd Add some text
    > Label lbl = new Label();
    > lbl.Text = " Now you see me!";
    > ctrl.Controls.Add(lbl);
    > }
    >}
    >
    >On the aspx page containing the usercontrol:
    >
    ><form id="Form1" method="post" runat="server">
    > <asp:panel id="MyPanel" visible="False"
    runat="server">Hello</asp:panel>
    > <kk:MyControl id="MyControl" runat="server" />
    ></form>
    >
    > From a design perspective I'd be wary of doing this
    because you are
    >creating a dependancy in the containing page and
    introducing some tight
    >coupling that will affect the user control's re-use in
    other pages..
    >
    >HTH
    >Kev
    >
    >
    >.
    >
    Lokhan Wong Guest

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