FindControl

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ravikanth[MVP]

    #1

    FindControl

    Hi

    FindControl method is to locate a control with an ID
    property of <<Control>> on the containing page.

    Check ChannelPanelId after adding the Display Panel.

    HTH
    Ravikanth

    [color=blue]
    >-----Original Message-----
    >I know I am doing or understanding something wrong. This
    >is a code snipet from a server control that accesses the
    >MCMS channel structure to build a dynamic cascading menu
    >system. While this is not the actual code (too[/color]
    extensive)[color=blue]
    >it performs the key function and provides the same
    >unsatisfacto ry results:
    >
    >Channel current = CurrentContext. Channel;
    >Panel Display = new Panel();
    >
    >foreach(Channe l subchannel in current.Channel s)
    >{
    > Panel channelPanel = new Panel();
    > channelPanel.ID = subchannel.Name ;
    > Display.Control s.Add(channelPa nel)
    >}
    >
    >string chName = current.Channel s[0].Name;
    >Panel foundPanel = Display.FindCon trol(chName);
    >
    >It seems that since there are 3 subchannels to current,
    >foundPanel should return the first Panel added in the
    >foreach loop. It doesn't. It returns null. Why?
    >
    >Thanks.
    >.
    >[/color]
  • Tim Pacl

    #2
    FindControl

    Is there no way of finding the embedded panel prior to
    rendering?
    [color=blue]
    >-----Original Message-----
    >Hi
    >
    >FindControl method is to locate a control with an ID
    >property of <<Control>> on the containing page.
    >
    >Check ChannelPanelId after adding the Display Panel.
    >
    >HTH
    >Ravikanth
    >
    >[color=green]
    >>-----Original Message-----
    >>I know I am doing or understanding something wrong.[/color][/color]
    This[color=blue][color=green]
    >>is a code snipet from a server control that accesses[/color][/color]
    the[color=blue][color=green]
    >>MCMS channel structure to build a dynamic cascading[/color][/color]
    menu[color=blue][color=green]
    >>system. While this is not the actual code (too[/color]
    >extensive)[color=green]
    >>it performs the key function and provides the same
    >>unsatisfactor y results:
    >>
    >>Channel current = CurrentContext. Channel;
    >>Panel Display = new Panel();
    >>
    >>foreach(Chann el subchannel in current.Channel s)
    >>{
    >> Panel channelPanel = new Panel();
    >> channelPanel.ID = subchannel.Name ;
    >> Display.Control s.Add(channelPa nel)
    >>}
    >>
    >>string chName = current.Channel s[0].Name;
    >>Panel foundPanel = Display.FindCon trol(chName);
    >>
    >>It seems that since there are 3 subchannels to current,
    >>foundPanel should return the first Panel added in the
    >>foreach loop. It doesn't. It returns null. Why?
    >>
    >>Thanks.
    >>.
    >>[/color]
    >.
    >[/color]

    Comment

    • Yan-Hong Huang[MSFT]

      #3
      RE: FindControl

      Hello Tim,

      I moved the following codes into page_load and the pane could be found now.

      Display = new Panel();
      this.Controls.A dd(Display);
      String[] ids = new String[3];
      ids[0] = "panel1";
      ids[1] = "panel2";
      ids[2] = "panel3";

      foreach(Channel subchannel in current.Channel s)
      {
      Panel channelPanel = new Panel();
      channelPanel.ID = subchannel.Name ;
      Display.Control s.Add(channelPa nel)
      }

      Also, I defined Dispaly as a global varialbe as other controls.

      Please test it and let me know whether it is what you needed.

      Best regards,
      Yanhong Huang
      Microsoft Online Partner Support

      Get Secure! - www.microsoft.com/security
      This posting is provided "AS IS" with no warranties, and confers no rights.

      --------------------
      !Content-Class: urn:content-classes:message
      !From: "Tim Pacl" <timothy_pacl@d ell.com>
      !Sender: "Tim Pacl" <timothy_pacl@d ell.com>
      !References: <0a2a01c34d28$c c711720$a601280 a@phx.gbl> <067c01c34d2b$a 4e724d0$a001280 a@phx.gbl>
      !Subject: FindControl
      !Date: Fri, 18 Jul 2003 06:05:43 -0700
      !Lines: 49
      !Message-ID: <0a8901c34d2d$4 b94dce0$a601280 a@phx.gbl>
      !MIME-Version: 1.0
      !Content-Type: text/plain;
      ! charset="iso-8859-1"
      !Content-Transfer-Encoding: 7bit
      !X-Newsreader: Microsoft CDO for Windows 2000
      !X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
      !Thread-Index: AcNNLUuU99knTW0 oSzKU98ENrW0k+w ==
      !Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
      !Path: cpmsftngxa06.ph x.gbl
      !Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1602 47
      !NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
      !X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
      !
      !Is there no way of finding the embedded panel prior to
      !rendering?
      !
      !>-----Original Message-----
      !>Hi
      !>
      !>FindControl method is to locate a control with an ID
      !>property of <<Control>> on the containing page.
      !>
      !>Check ChannelPanelId after adding the Display Panel.
      !>
      !>HTH
      !>Ravikanth
      !>
      !>
      !>>-----Original Message-----
      !>>I know I am doing or understanding something wrong.
      !This
      !>>is a code snipet from a server control that accesses
      !the
      !>>MCMS channel structure to build a dynamic cascading
      !menu
      !>>system. While this is not the actual code (too
      !>extensive)
      !>>it performs the key function and provides the same
      !>>unsatisfacto ry results:
      !>>
      !>>Channel current = CurrentContext. Channel;
      !>>Panel Display = new Panel();
      !>>
      !>>foreach(Chan nel subchannel in current.Channel s)
      !>>{
      !>> Panel channelPanel = new Panel();
      !>> channelPanel.ID = subchannel.Name ;
      !>> Display.Control s.Add(channelPa nel)
      !>>}
      !>>
      !>>string chName = current.Channel s[0].Name;
      !>>Panel foundPanel = Display.FindCon trol(chName);
      !>>
      !>>It seems that since there are 3 subchannels to current,
      !>>foundPanel should return the first Panel added in the
      !>>foreach loop. It doesn't. It returns null. Why?
      !>>
      !>>Thanks.
      !>>.
      !>>
      !>.
      !>
      !


      Comment

      Working...