Results 1 to 28 of 28

Thread: [RESOLVED] AutoEventWire up + Confusion

  1. #1
    Hyperactive Member
    Join Date
    Apr 08
    Posts
    456

    Resolved [RESOLVED] AutoEventWire up + Confusion

    hi frnds by default AutoEventwireup value is false.If value is true we do not have to write the below event InitializeComponent. But by default, value is false & even we do not write the foll. event InitializeComponent ,then how the page load is called????

    If it's set to "True", the ASP.NET runtime does not require events to specify event handlers like Page_Load etc.,

    Once you create a new webform in VS.NET the 'AutoEventWireup' attribute of that page would be false. Open the code behind file and check out the 'InitializeComponent' it would be something like this:

    private void InitializeComponent()
    {
    this.Load += new System.EventHandler(this.Page_Load);
    }

  2. #2
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 04
    Location
    Inside the CPU...
    Posts
    6,479

    Re: AutoEventWire up + Confusion

    When AutoEventWireup is True, you do not need to associate the event handlers. It automatically associates the event handlers for you. The procedure name should be in a specific format for this to work i.e. Object_Event. e.g. Page_Init, Page_Load

    When AutoEventWireup is False, then you need to explicitly associate event handlers with the corresponding methods, in one or the other way. This does not need you to name the procedure in any specific format. Also, this is better performancewise as compared to AutoEventWireup=True.

    The default value of AutoEventWireup is True. So when you don't specify, this is True.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog • 101 LINQ Samples • JSON Validator • XML Schema Validator • "How Do I" videos on MSDN • VB.NET and C# Comparison • Good Coding Practices • VBForums Reputation Saver • String Enum • Super Simple Tetris Game


    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  3. #3
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 04
    Location
    Inside the CPU...
    Posts
    6,479
    Last edited by Pradeep1210; Nov 30th, 2009 at 01:56 PM.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog • 101 LINQ Samples • JSON Validator • XML Schema Validator • "How Do I" videos on MSDN • VB.NET and C# Comparison • Good Coding Practices • VBForums Reputation Saver • String Enum • Super Simple Tetris Game


    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  4. #4
    Hyperactive Member
    Join Date
    Apr 08
    Posts
    456

    Re: AutoEventWire up + Confusion

    hello pradeep sir.These two sites are not opened in my computer,cz msdn sites are not opened up in my computer.

    Suppose I set the AutoEventWireUp=False.Then the page load event is not called by itself.I want to ask that how to generate event private void InitializeComponent()
    {
    this.Load += new System.EventHandler(this.Page_Load);
    } .
    To generate page load event we just double click on form.& event is generated.How to generate InitializeComponent event.

  5. #5
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 04
    Location
    VBForums
    Posts
    5,815

    Re: AutoEventWire up + Confusion

    Normally if you create one project and adds one form the InitializeComponent will get added to the page.
    Please mark you thread resolved using the Thread Tools as shown



    Windows 8 Developer Preview Available For Download
    www.techreceipe.com




  6. #6
    Hyperactive Member
    Join Date
    Apr 08
    Posts
    456

    Re: AutoEventWire up + Confusion

    I m not able to see that,I add the form & generate load event,i see the foll. code-
    Code:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    
    public partial class Default3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    }
    Where is the Initailize Component event??????

  7. #7
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 04
    Location
    VBForums
    Posts
    5,815

    Re: AutoEventWire up + Confusion

    Sorry for my mistake. I thought it is an Windows Application.

    Yes in Web Application it is not calling the Page_Load event if you set the event wireup to false. For this create one Public Constructor with the Page name and associate the Page Load event there as

    Code:
    public _Default()
        {
            this.Load += new EventHandler(Page_Load);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    Please mark you thread resolved using the Thread Tools as shown



    Windows 8 Developer Preview Available For Download
    www.techreceipe.com




  8. #8
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,731

    Re: AutoEventWire up + Confusion

    Quote Originally Posted by sonia.sardana View Post
    hello pradeep sir.These two sites are not opened in my computer,cz msdn sites are not opened up in my computer.
    I have to ask...

    Why are you not allowed access to MSDN? For a programmer, this is a critical resource!!

    Gary

  9. #9
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 04
    Location
    VBForums
    Posts
    5,815

    Re: AutoEventWire up + Confusion

    Or You could override the OnInit method of the page

    Code:
    //public _Default()
        //{
        //    this.Load += new EventHandler(Page_Load);
        //}
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected override void OnInit(EventArgs e)
        {
            this.Load += new EventHandler(Page_Load);
        }
    MSDN
    Please mark you thread resolved using the Thread Tools as shown



    Windows 8 Developer Preview Available For Download
    www.techreceipe.com




  10. #10
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 04
    Location
    VBForums
    Posts
    5,815

    Re: AutoEventWire up + Confusion

    Quote Originally Posted by gep13 View Post
    I have to ask...

    Why are you not allowed access to MSDN? For a programmer, this is a critical resource!!

    Gary
    I too agree with Gary. Here the people don't have any sense. I strongly believe that if you are Microsoft developer, you should be allowed to access MSDN . I believe the fellow is from India
    Please mark you thread resolved using the Thread Tools as shown



    Windows 8 Developer Preview Available For Download
    www.techreceipe.com




  11. #11
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,731

    Re: AutoEventWire up + Confusion

    I would be interested to know the reason that they are not allowed access though. The whole concept seems very strange to me.

    All due respect to this forum, but I would have thought access to public forums would have been restricted before a reputed website like MSDN.

    Just my opinion.

    Gary

  12. #12
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 02
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    Re: AutoEventWire up + Confusion

    What reason do you need the InitializeComponent for? There's no component to initialize on a web page. If you're looking for an early method, use Init or PreInit.

    If you're looking for an easy way to generate them, go to your page view, go to properties window, then click on the lightning bolt. Pick the event you want there, double click in its empty space and it should generate the event for you.

  13. #13
    Hyperactive Member
    Join Date
    Apr 08
    Posts
    456

    Re: AutoEventWire up + Confusion

    hey guys,I cant access msdn at my home not in office.

    Thx danasegarane sir, problem regarding the AutoEventWireup is solved.

    hi mendhak sir,I right click the properties of page view(white portion of .aspx page),But i m not any lightning bolt,see in pic.
    Attached Images Attached Images  

  14. #14
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,731

    Re: AutoEventWire up + Confusion

    Hello Sonia,

    This is what mendhak was referring to:

    Name:  Thunderbolt.png
Views: 31
Size:  8.8 KB

    Select the object that you want to create the event handler for, then select the thunderbolt.

    I have to ask again...

    Why can't you access MSDN from your home?

    Gary

  15. #15
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 04
    Location
    VBForums
    Posts
    5,815

    Re: AutoEventWire up + Confusion

    I agree with Sonia.

    Here is the method of getting the Page events
    1.Select the page
    2.Right Click, Choose Component Designer, Will display designer.
    3.In the Designer , Right Click --> Properties
    4. Highlight the thunder icon. Now you will get the Page Events

    See the Attached Image
    Attached Images Attached Images  
    Please mark you thread resolved using the Thread Tools as shown



    Windows 8 Developer Preview Available For Download
    www.techreceipe.com




  16. #16
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,731

    Re: AutoEventWire up + Confusion

    Ah, my bad, I missed the fact that we were talking about page events. (Don't know how I missed that )

    Gary

  17. #17
    Hyperactive Member
    Join Date
    Apr 08
    Posts
    456

    Re: AutoEventWire up + Confusion

    hi danasegarane thx very much.Tell me one thing more- first method,i write manually.Second method,is generated by your method. They are same or not.??
    Because if i write AutoEventWireup to False,then the first method is executed not second one.

    FIRST
    protected override void OnInit(EventArgs e)
    {
    this.Load += new EventHandler(Page_Load);
    }

    SECOND
    private void FrmXML_Init(object sender, EventArgs e)
    {
    this.Load += new EventHandler(Page_Load);
    }

  18. #18
    Hyperactive Member
    Join Date
    Apr 08
    Posts
    456

    Re: AutoEventWire up + Confusion

    I dont know Gep sir,y cant i access MSN from home.Everytime i open msdn page,server not found.I try it in all browsers firefox,chrome,But still cant access msdn??? hey Gep sir i want to ask one thing more,VS 2008 is avaialbe thru net free of cost or not?

  19. #19
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,731

    Re: AutoEventWire up + Confusion

    Hey,

    You can get the Visual Studio 2008 Express Editions for free, yes:

    http://www.microsoft.com/exPress/

    Gary

  20. #20
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 04
    Location
    VBForums
    Posts
    5,815

    Re: AutoEventWire up + Confusion

    Note this points

    I am over riding the OnInit method. But you are not doing
    Please mark you thread resolved using the Thread Tools as shown



    Windows 8 Developer Preview Available For Download
    www.techreceipe.com




  21. #21
    Hyperactive Member
    Join Date
    Apr 08
    Posts
    456

    Re: AutoEventWire up + Confusion

    Wats the difference b/w express & full version???Can u tell me??In express,it supports AJAX controls??

  22. #22
    Hyperactive Member
    Join Date
    Apr 08
    Posts
    456

    Re: AutoEventWire up + Confusion

    k k sorry V Sir ,OnInit cannot be generated automatically thru your method,We have to write it manually rite????

  23. #23
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,731

    Re: AutoEventWire up + Confusion

    Quote Originally Posted by sonia.sardana View Post
    Wats the difference b/w express & full version???Can u tell me??In express,it supports AJAX controls??
    I think this will help you:

    http://www.microsoft.com/downloads/d...DisplayLang=en

    The short answer though is, yes.

  24. #24
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 04
    Location
    VBForums
    Posts
    5,815

    Re: AutoEventWire up + Confusion

    Quote Originally Posted by sonia.sardana View Post
    I m not able to see that,I add the form & generate load event,i see the foll. code-
    Code:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    
    public partial class Default3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    }
    Where is the Initailize Component event??????
    Quote Originally Posted by gep13 View Post
    Hey,

    You can get the Visual Studio 2008 Express Editions for free, yes:

    http://www.microsoft.com/exPress/

    Gary
    If you are more interested in Web Application I will suggest for Visual Web Developer
    Please mark you thread resolved using the Thread Tools as shown



    Windows 8 Developer Preview Available For Download
    www.techreceipe.com




  25. #25
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,731

    Re: AutoEventWire up + Confusion

    Hey Dana,

    I was assuming that this was the case for the OP, but you are correct to point it out.

    Gary

  26. #26
    Hyperactive Member
    Join Date
    Apr 08
    Posts
    456

    Re: AutoEventWire up + Confusion

    hey read the foll. info,Read the bolded part.Its wrong na.by default AutoEventWireup is true ,but below written false,in 2005 we write OnInit event if we set AutoEventWireup to False,but below writen in InitializeComponent() we write??? Below is the case for VS 2003,if i m not wrong???? Last Question!!!!!!

    AutoEventWireup is an attribute in Page directive. It's a Boolean attribute which indicates whether the asp.net pages events are auto-wired.

    AutoEventWireup will have a value true or false. By default its value is set to false. We can specify the default value of the AutoEventWireup attribute in the following locations:

    - The Machine.config file.
    - The Web.config file.
    - Individual Web Forms (.aspx files).
    - Web User Controls (.ascx files)

    In Machine.Config or WebConfig file this attribute can be declared as

    <configuration>
    <system.web> <pages autoEventWireup="true|false" /> </system.web> </configuration>

    As we know, when we change Machine.Config file, it will affect all asp.net webforms on the computer and if we change Web.config it will affect that application only. If you want this attribute change in a single webform change in page directive

    Understanding its working

    AutoEventWireup is false when we create a new web application and event handlers are automatically created. We can find this in the Initialize Component method

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

  27. #27
    Hyperactive Member
    Join Date
    Apr 08
    Posts
    456

    Re: [RESOLVED] AutoEventWire up + Confusion

    hey frnds your contribution make this site just Rocking!!!!!!!!!!!!!!!

  28. #28
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 02
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    Re: [RESOLVED] AutoEventWire up + Confusion

    That article is talking about web applications. You may be dealing with web sites which is a different type of project.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •