Beginners are always confused about AutoEventWireup attribute of a Page directive. In this blog, I will explain AutoEventWireup and try to help out beginners. I hope programmers wouldn’t confuse about AutoEventWireup attribute after read this blog. When I create a new aspx page, Page directives have four attributes – Language, AutoEventWireup, CodeFile, and Inherits.
AutoEventWireup – AutoEventWireup attribute indicate whether ASP.NET pages events are auto – wired or not. It’s a Boolean attribute (accept True or false). If AutoEventWireup is set to true, some page methods are called automatically. Below is the list of methods which automatically called when AutoEventWireup is set to true -
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AutoEventWireUpTest.aspx.cs" Inherits="AutoEventWireUpTest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<form id="form1" runat="server">
<asp:Button ID="btnTest" runat="server" Text="Click" onclick="btnTest_Click" />
public partial class AutoEventWireUpTest : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
Response.Write("This is Page Load Event..." + "<br />");
protected void Page_PreInit(object sender, EventArgs e)
Response.Write("This is Page PreInit Event..." + "<br />");
protected void btnTest_Click(object sender, EventArgs e)
Response.Write("This is Button Click Event after click on the button..." + "<br />");
If AutoEventWireup is set to false, output is -
There are following way to specify the AutoEventWireup attribute -
<%@ Page AutoEventWireup="false" %>
<%@ Control AutoEventWireup="true" %>
This comment is awaiting moderation.
You may need to change the package name for your android application due to various reasons ranging from a small typo to duplicate domain name. Changing the package name ...
by: Ravi Rawal
If you are looking for dynamically adding different types of "Widgets" into your screen programatically and are also interested in placing them such that many items are v...
This blog teaches you to display line numbers in visual studio text editor.
by: Yukti Arora
This blog teaches you to switch themes in visual studio.
Toast message is a way to provide some information to the user that stays on the screen for a couple of seconds. Here, we will be working on how to beautify that message ...
Adobe has been keeping busy for a few months now working on the new features for Photoshop CC 2015. And finally they released a new version recently. The engineers worked...
by: Atul Ahuja
What kind of email newsletter would you prefer to receive from CodeAsp.Net?