I want to add a C# class to an existing SharePoint 2010 site page. The site page, being created either through the SharePoint UI or in SharePoint Designer, has a web part on it that I want to access and edit its properties. I could just make an invisible web part in Visual Studio, deploy it on the page, and run the code I want to run that way, but I feel like that may be bad practice (or is it)?
I'm kind of talking about how a general non-SharePoint .aspx page can reference a C# file, kind of like below:
<%@ Page language="C#" Inherits="System.Web.UI.Page" CodeFile="Example.cs" %>
Would a line like above be added to the .aspx file? How is the .cs file actually deployed on the SharePoint site? Finally, is this even possible?
I'm new to SharePoint and to this site, so I appreciate all help!