Page_Load not firing in web user control ascx.vb

C

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
 
C

Chris Jackson

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.
 
C

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
 

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,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top