By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,098 Members | 1,881 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,098 IT Pros & Developers. It's quick & easy.

UserControl Page_InitComplete

P: n/a
based on MSPress's ASP.NET 2.0 Applications Advaced Topics ( Table 12-3
p.472 ), and
most events should be automatically wired up when @Control
AutoEventWireup="true".
ie. Page_InitComplete() {} should be invoked automatically without having to
wire up the event as : Page.InitComplete+=new
EventHandler(Page_InitComplete);
It seems that this is only true for a fairly restricted set of events which
does not include Page_InitComplete.
I thought that maybe a call to UserControl.InitializeAsUserControl() ( ibid
Table12-2 ) might be necessary but this method seems to be non-existant.
Is the documentation wrong or have I missed a setting somewhere ?
Also, when working with WebForms,UserControls etc in VS2005, thecontrol/page
itself is no longer listed on the control list at the top of properties
window as it was in vs2003 which means that all properties & events must be
set/added/wired up manually unlike other controls. Is there a new way to
access properties and events for WebForms & UserControls or is there a
setting i've missed to add these back to the property editor or did MS
remove this capability for some reason ?

Gerry
Aug 17 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Thanks Steven,

I will see where I can submit an errata report to mspress regarding the
autoevent wireup for user controls in the book mentioned - i did look for
this initially but found none. As the book specifically states that the
autoamatic event hookup for usercontrols includes a list of 16 events and
not just the 9 you have listed.

My work around for form/control events was to enter override[space] in the
code view which causes intellisense to list all overridables for the current
class' base classes. But for a supposed RAD ide this to me is a big step
backwards. I will submit some feedback on this point as suggested.

Gerry
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:eC**************@TK2MSFTNGXA01.phx.gbl...
Hello Gerry,

As for the AutoEventWireup setting of the ASP.NET @Page and @Control
directive, I think your understanding is right. When we turn on the
"AutoEventWireup" of the @Page and @Control directive, we can directly
write event handler functions for Page or UserControl without explicitly
registering them.

As for the following symptom you mentioned
==================
It seems that this is only true for a fairly restricted set of events
which
does not include Page_InitComplete.
==================

this is actually due to the limited events of the UserControl rather than
the ability of "AutoEventWireup" support. As in the class library
reference
below, we can find that all the available events of UserControl are:

AbortTransaction
CommitTransaction
DataBinding
Disposed
Error
Init
Load
PreRender
Unload
#UserControl Events
http://msdn2.microsoft.com/en-us/library/d6thxdk7.aspx

For the above events, we can directly put event handler function in
codebehind when "AutoEventWireup" is enabled. And some other Page specfiic
events such as "InitComplete", "LoadComplete" is not available for
UserControl.

===========================
Also, when working with WebForms,UserControls etc in VS2005,
thecontrol/page
itself is no longer listed on the control list at the top of properties
window as it was in vs2003 which means that all properties & events must
be
set/added/wired up manually unlike other controls.
===========================

Yes, I've also noticed this limitation of the c# source code editor for
page/usercontrol. In VS 2003, since all the page and codebehind class is a
single file class(rather than the partial class which need to compile
together with aspx/ascx), we can manipulate its events like normal
controls
on the page in Properties Windows. And in VS 2005, VB.NET page still
supports select events from dropdownlist to add event handler(and by
default autoeventwireup is turn off for VB.NET page).
Currently, what I usually do for VS 2005 cs page/usercontrol when try
adding eventhandler function is:

* in a page function, type "this" keyword and let the page member
intellisense windows popup

* in the popup intellsense member window, we can view all the available
events of the current class(this),

* type the event handler function according to the event name , ( "Page_"
+
EVENT_NAME), and the function signature of these basic events are all

FUNCTIONNAME(object sender, EventArgs e)

Hope this would help a little for you to locate a certain page/usercontrol
event. (I've attached a screenshot on this and you can get it if you're
using Outlook express to visit the newsgroup)

Here is the msdn document describing creating event handler for web page
in
VS 2005:

#How to: Create Event Handlers in ASP.NET Web Pages (Visual Studio)
http://msdn2.microsoft.com/en-us/library/6w2tb12s.aspx
In addition, I think this is a reasonable request and would suggest you
supply a request in our pubilc feedback center so that our dev team can
also hear such feedback from community which is quite important for the
sequential version of the Dev Studio/tools. Any of your feedback and
comment is really appreciated.

#Visual Studio and .NET Framework Feedback
http://connect.microsoft.com/feedbac...spx?SiteID=210
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.
>




Aug 21 '06 #2

P: n/a
Thanks for your followup Gerry,

Yes, the book's statement seems a bit incorrect according to Usercontrol's
supported model. Sure, you can also submit the request of the errata.

If there is anything else we can help or any other information you wonder,
please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.