470,590 Members | 2,556 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,590 developers. It's quick & easy.

Page_Load not firing in web user control ascx.vb

C K
I am having trouble getting the page_load event to fire from within my
usercontrol - my code is below, I'm sure I'm missing something simple.

Just your basic web user control - I've just began using them.
My aspx page is simple:

<%@ Register TagPrefix="TestPoll" TagName="Message" Src="poll.ascx" %>
....
<form id="Form1" method="post" runat="server">
<TestPoll:Message runat="server" ID="Message1"/>
</form>
....
My user control is also plain jane- I have a label on it called label1 -
here is my code in the *.ascx.vb file. I can get a button_click event to
fire from code contained in the *.ascx.vb

Sub Page_Load(ByVal Src As Object, ByVal E As EventArgs)
Label1.Text = "run" 'c.LastName
End Sub

What am I missing?

Clayton
Nov 17 '05 #1
2 11193
You may want to expand the Web Form Designer generated code region and make
sure that there is an event handler set up for the page load event. I'm not
a VB guy, but in C# you need to have:

this.Load += new System.EventHandler(this.Page_Load);

You'll want to have something similar.
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows XP
Windows XP Associate Expert
--
"C K" <ca*****************@homtail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I am having trouble getting the page_load event to fire from within my
usercontrol - my code is below, I'm sure I'm missing something simple.

Just your basic web user control - I've just began using them.
My aspx page is simple:

<%@ Register TagPrefix="TestPoll" TagName="Message" Src="poll.ascx" %>
...
<form id="Form1" method="post" runat="server">
<TestPoll:Message runat="server" ID="Message1"/>
</form>
...
My user control is also plain jane- I have a label on it called label1 -
here is my code in the *.ascx.vb file. I can get a button_click event to
fire from code contained in the *.ascx.vb

Sub Page_Load(ByVal Src As Object, ByVal E As EventArgs)
Label1.Text = "run" 'c.LastName
End Sub

What am I missing?

Clayton

Nov 17 '05 #2
C K
Thanks guys.

I added "Handles MyBase.Load" to the end of the page_load declaration and it
works.

New Code:
Sub Page_Load(ByVal Src As Object, ByVal E As EventArgs) Handles MyBase.Load

Old Code:

Sub Page_Load(ByVal Src As Object, ByVal E As EventArgs)

Also, an alternative would be to change the autoeventwireup = true (VS
defaults it to false)

Cheers,

Clayton

"Dino Chiesa [MSFT]" <di****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
May want to turn on trace in the app
eg

<%@ Page Language="VB"
Debug="true"
Trace="true"
%>

"Chris Jackson" <ch****@mvps.org> wrote in message
news:Oj*************@tk2msftngp13.phx.gbl...
You may want to expand the Web Form Designer generated code region and

make
sure that there is an event handler set up for the page load event. I'm

not
a VB guy, but in C# you need to have:

this.Load += new System.EventHandler(this.Page_Load);

You'll want to have something similar.
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows XP
Windows XP Associate Expert
--
"C K" <ca*****************@homtail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I am having trouble getting the page_load event to fire from within my
usercontrol - my code is below, I'm sure I'm missing something simple.

Just your basic web user control - I've just began using them.
My aspx page is simple:

<%@ Register TagPrefix="TestPoll" TagName="Message" Src="poll.ascx" %>
...
<form id="Form1" method="post" runat="server">
<TestPoll:Message runat="server" ID="Message1"/>
</form>
...
My user control is also plain jane- I have a label on it called label1 - here is my code in the *.ascx.vb file. I can get a button_click event to fire from code contained in the *.ascx.vb

Sub Page_Load(ByVal Src As Object, ByVal E As EventArgs)
Label1.Text = "run" 'c.LastName
End Sub

What am I missing?

Clayton



Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by H Branyan | last post: by
2 posts views Thread by dx | last post: by
14 posts views Thread by V. Jenks | last post: by
1 post views Thread by Luis Esteban Valencia Muñoz | last post: by
2 posts views Thread by Sosh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.