Page directive like this
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
HTML
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
The following code should be inside Default.aspx.cs
protected void Button1_Click(object sender, EventArgs e) { Page.Title = "Sample Text"; }
My guess about where the problem might be may be the problem in the directive
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
otherwise you would not name the asp: Button tag inside the form tag
<form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </div> </form>
source share