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

E

et

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,097
Latest member
RayE496148

Latest Threads

Top