tags:

views:

67

answers:

2

Trying to create a simple form:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="register.aspx.cs" Inherits="AlphaPack._Default"
    MasterPageFile="MasterPages/Main.master"
    title="Hi there!"
%>

<script runat="server">
    public void regSubmit()
    {
        statusLabel.Text = "Submitted!";
    }
</script>

<asp:content id="Content1" contentplaceholderid="mainContent" runat="server">


<form id="registerForm" runat="server">

<asp:Label runat="server" id="statusLabel"></asp:Label>
<asp:Button id="id" text="Register" OnClick="regSubmit" runat="server" />

</form>

</asp:content>

hope it's obvious what I'm trying to do, someone clicks the button and it submits the form and changes the label text.

Compiler Error Message: CS0123: No overload for 'regSubmit' matches delegate 'System.EventHandler'

I know I'm doing something fundamentally wrong here, i'm new to .net moving over from classic ASP.

+6  A: 

Try this:

protected void regSubmit(object sender, EventArgs e)
Burt
Super thanks! I'll look up those parameters
Tom Gullen
@Tom: For the record, all events in .NET have two arguments: an `Object` (whose event it is) and an `EventArgs` instance (or one of its subclasses).
R. Bemrose
+4  A: 

Because it's an event handler, your click method needs to have the proper signature of

public void regSubmit(object sender, EventArgs e)

Jon Skeet wrote an article on understanding Delegates and Events. Going over that may help you with these sort of issues in the future.

statenjason