How to Create a C# Web Form Page, Within One Page

Soldato
Joined
24 Sep 2007
Posts
5,180
Hi Guys

I am learning C#, and I want to see if I can create a C# contact form. For ease of setup, I am hoping this can be done by creating a single .aspx and putting the C# code onto the page. Can this be done? I have a C# function that I want the form to call on the Submit button event. I have put the function into <% %> tags, but that doesn't seem to be working. Can anyone help? I just want to know the basic setup of web pages so that you can use C# code on them.

Thanks
 
Any thoughts guys? I just need to know what to put on a single .aspx page for it to run C#. I will start Googling, but if anyone could point me in the right direction ...
 
OK I've worked it out. For reference:

At the top of the .aspx page:

<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System" %>

Then in the html head section, put your C# code within script tags:

<script language="C#" runat="server"> ... </script>
 
Back
Top Bottom