Load User Control on link click

Discussion in 'ASP .Net Web Controls' started by Kiki, Jul 6, 2004.

  1. Kiki

    Kiki Guest

    Hello,
    i'm a newbie on .NET so not even sure what i can and cannot do.
    Here's the deal.
    I have 2 user controls on a page: one is the left side menu and in the
    middle there are some linkable images. What i'd like to do is, instead
    of redirecting to a page when a link (from the menu or the image) is
    clicked, so load a control on the right of the page that will display
    some info, thus allowing the user to have a quick look to decide
    whether or not he/she wants to view the page.. Initially, this 3rd
    control will be something general and then, after the user selects an
    item it will load the appropriate control.
    Is this possible?
    in short...

    <table>
    <tr>
    <td align="left" width="20%">
    <asp:placeholder id="ph1" runat="server" />
    </td>
    <td align="center" width="40%">
    <asp:placeholder id="ph2" runat="server" />
    </td>
    <td align="right" width="20%">
    <asp:placeholder id="ph3" runat="server" />
    </td>
    </tr>
    </table>

    private void Page_Load(object sender, System.EventArgs e)
    {
    LeftMenu leftMenuControl = (LeftMenu) LoadControl
    ("UserControls/LeftMenu.ascx");
    this.ph1.Controls.Add(leftMenuControl);
    Control secondControl= (Control )
    LoadControl("UserControls/SecondControl.ascx");
    this.ph2.Controls.Add(secondControl);
    }

    i hope this is clear and thank you for your help.

    K
     
    Kiki, Jul 6, 2004
    #1
    1. Advertisements

  2. Kiki

    Bobby Ryzhy Guest

    You will have to use <div> tags and javascript to make them visible
    and not.

    example:
    <script language="javascript">
    <!--
    function ShowDiv(divToShow)
    {
    var objs = document.all;

    for (var i=0; i<objs.length; i++)
    {
    if (objs.id.indexOf('linkDiv') == -1)
    {
    if (objs.style.visibility == 'visible')
    {
    objs.style.visibility = 'hidden'
    objs.style.display = 'none'
    }
    }
    }

    var obj = document.getElementById(divToShow);

    if (typeof(obj) != "undefined")
    {
    obj.style.visibility = 'visible';
    obj.style.display = 'block';
    }
    }
    -->
    </script>

    <div id="Div1" style="DISPLAY: none; VISIBILITY: hidden"
    runat="server">
    CONTENT
    </div>


    Bobby Ryzhy
    bobby@ name of domain below
    http://www.weekendtech.net



    On 6 Jul 2004 07:36:27 -0700, (Kiki) wrote:

    >Hello,
    >i'm a newbie on .NET so not even sure what i can and cannot do.
    >Here's the deal.
    >I have 2 user controls on a page: one is the left side menu and in the
    >middle there are some linkable images. What i'd like to do is, instead
    >of redirecting to a page when a link (from the menu or the image) is
    >clicked, so load a control on the right of the page that will display
    >some info, thus allowing the user to have a quick look to decide
    >whether or not he/she wants to view the page.. Initially, this 3rd
    >control will be something general and then, after the user selects an
    >item it will load the appropriate control.
    >Is this possible?
    >in short...
    >
    ><table>
    > <tr>
    > <td align="left" width="20%">
    > <asp:placeholder id="ph1" runat="server" />
    > </td>
    > <td align="center" width="40%">
    > <asp:placeholder id="ph2" runat="server" />
    > </td>
    > <td align="right" width="20%">
    > <asp:placeholder id="ph3" runat="server" />
    > </td>
    > </tr>
    ></table>
    >
    >private void Page_Load(object sender, System.EventArgs e)
    >{
    > LeftMenu leftMenuControl = (LeftMenu) LoadControl
    >("UserControls/LeftMenu.ascx");
    > this.ph1.Controls.Add(leftMenuControl);
    > Control secondControl= (Control )
    >LoadControl("UserControls/SecondControl.ascx");
    > this.ph2.Controls.Add(secondControl);
    >}
    >
    >i hope this is clear and thank you for your help.
    >
    >K
     
    Bobby Ryzhy, Jul 7, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moondaddy
    Replies:
    1
    Views:
    1,966
    moondaddy
    May 4, 2004
  2. =?Utf-8?B?U3JpZGhhcg==?=
    Replies:
    1
    Views:
    551
    =?Utf-8?B?RWx0b24gVw==?=
    Nov 18, 2005
  3. Mad Scientist Jr
    Replies:
    0
    Views:
    906
    Mad Scientist Jr
    Mar 22, 2006
  4. Max2006
    Replies:
    2
    Views:
    1,833
    Walter Wang [MSFT]
    Sep 19, 2007
  5. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    812
    Jonathan Wood
    Feb 2, 2010
  6. Blue®
    Replies:
    4
    Views:
    1,227
    Blue®
    Sep 27, 2003
  7. Peter Michaux

    Synthetic click on link doesn't follow link

    Peter Michaux, Jun 4, 2007, in forum: Javascript
    Replies:
    2
    Views:
    309
    -Lost
    Jun 5, 2007
  8. Daniish
    Replies:
    2
    Views:
    417
    Thomas 'PointedEars' Lahn
    Jun 13, 2008
Loading...