Interaction with UserControls (ascx)?

F

Frank Schumacher

Hi NG,

I have 2 problems working with an user control (ascx) and couldn't find
a solution yet.
I created a simple ascx with some ImageButtons and drag it on a simple
Webform, this code was inserted:

<%@ Register TagPrefix="uc1" TagName="chunk_container"
Src="chunk_container/chunk_container.ascx" %>

and in the body-tag:

<uc1:chunk_container id="Chunk_container1"
runat="server"></uc1:chunk_container>

1.) the Page_Load function of the ascx isn't execuded. It seems that the
ascx doesn't receive the event

2.) as shown above, an instance of my UserControl is created within the
body-tag, but I do not have any reference in my code behind. I'd expect
something like
protected Namespace.chunk_container Chunk_container1;

but there ain't such declaration. So I cannot access the functions, that
are public in my UserControl (and essential for the use of it).

I'm afraid, that I am completely out of line and hope, someone here can
give me a clue, how to solve this problems.

Thanks in advance,
Frank

PS: I am using VS.NET 2003, C#, W2003
 
S

Scott Mitchell [MVP]

Frank said:
1.) the Page_Load function of the ascx isn't execuded. It seems that the
ascx doesn't receive the event

What does your @Control tag in the User Control look like?

2.) as shown above, an instance of my UserControl is created within the
body-tag, but I do not have any reference in my code behind. I'd expect
something like
protected Namespace.chunk_container Chunk_container1;

Sadly, you have to add that manually. :-/

Also, might I suggest that you check out my article:

An Extensive Examination of User Controls
http://tinyurl.com/6nddj

Happy Programming!

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
F

Frank Schumacher

Hallo Scott
What does your @Control tag in the User Control look like?

I have checked the statement and found an "AutoEventWireUp" Attribut
which was set to false. After changing it to true, the user control got
its events.
Sadly, you have to add that manually. :-/

As long as I know that I have to add it manually, it is no problem. Now
I know it, so no problem anymore .. :)
Also, might I suggest that you check out my article:

An Extensive Examination of User Controls
http://tinyurl.com/6nddj

I have done it and found some answers, even on questions that might be
arise in the future ...
Happy Programming!

It became a bit happier now .. thanks for the input!

Frank
 
F

Frank Schumacher

Hi Saravana,

thanks for the link! It wasn't exactly what I was looking for, but
interesting anyway. I just don't understand, why the author mourned
about not being able to use inline server scripting. Why would anyone
use inlining now that we have code behind?

Ciao,
Frank
 

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

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top