Getting data from a usercontrol before containing page ends its page load

Discussion in 'ASP .Net Building Controls' started by et, Sep 7, 2004.

  1. et

    et Guest

    How do I load a user control in a web form first, so that the web form's
    page_load acts according to events on the user control?

    In my code below, I have a user control at the top of every web form, in a
    panel. I have 2 other panels on the web forms, to be shown individually
    depending on what the user clicks on the user control. However, when the
    button on the user control is clicked, the web form page_load fires first,
    then the control's page_load, then the event of the button click in the user
    control fires last, so there is no response from the web form because it
    has already been loaded. What do I do about this, I've seen similar
    dilemmas in this newsgroup and find hundreds of articles in ms, but none
    that solve this one, unless I'm just not putting the pieces together.
    Thanks for any help, advice!

    index.aspx
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="index.aspx.vb"
    Inherits="WebForm1"%>
    <%@ Register TagPrefix="uc1" TagName="ucHeader" Src="ucHeader.ascx" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    <meta name=vs_defaultClientScript content="JavaScript">
    <meta name=vs_targetSchema
    content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body >

    <form id=frm1 runat=server>
    <asp:panel id=Panel1 runat="server">
    <uc1:ucHeader id=UcHeader1 runat="server"></uc1:ucHeader>
    </asp:panel>
    <asp:panel id=Panel2 runat="server">Panel 2</asp:panel>
    <asp:panel id=Panel3 runat="server">Panel 3</asp:panel>
    </form>
    </body>
    </HTML>


    index.aspx.vb
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    if not ispostback then
    if ucHeader.value = true then
    Panel2.Visible = True
    panel3.Visible = False
    else
    panel2.Visible=False
    panel3.Visible = true
    End If
    end if
    End Sub

    ucHeader.ascx
    <%@ Control Language="vb" classname="ucHeader" AutoEventWireup="false"
    Codebehind="ucHeader.ascx.vb" Inherits="WMIS.ucHeader"
    TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
    <TABLE id=header borderColor=black cellSpacing=0 cellPadding=0 width="100%">
    <TR align=center>
    <TD><asp:button id=btnABC Font-Bold="True" Text="Show Panel 1"
    runat="server"></asp:button></td>
    <TD><asp:button id=btnDEF Font-Bold="True" Text="Show Panel 2"
    runat="server"></asp:button></td></tr>
    </TABLE>
     
    et, Sep 7, 2004
    #1
    1. Advertising

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. ujjc001
    Replies:
    0
    Views:
    686
    ujjc001
    Jul 25, 2007
  2. Bob Murdoch

    Page load never ends

    Bob Murdoch, Dec 2, 2003, in forum: ASP General
    Replies:
    10
    Views:
    276
    Dave Anderson
    Dec 2, 2003
  3. thunk
    Replies:
    1
    Views:
    323
    thunk
    Mar 30, 2010
  4. thunk
    Replies:
    0
    Views:
    496
    thunk
    Apr 1, 2010
  5. thunk
    Replies:
    14
    Views:
    630
    thunk
    Apr 3, 2010
Loading...

Share This Page