Without going into .NET specifies, since that isn't my field:
Anything which runs on the client (e.g. JavaScript) is visible to users who can modify it, within the confines of their system, as much as they want.
Anything which runs on the server is not visible to users.
For a user to be able to click a button and have code on the server run, the browser must send an HTTP request to the server. The simple approach is to use a form. This provides a standard means to structure data.
More complicated approaches involve using JavaScript to construct the request explicitly (rather than just letting the browser take care of it). This lets the data be submitted using other methods than "Visiting a new page", which gives the flexibility needed for Ajax.
With any approach, you essentially define a public API which is accessible via HTTP.
There are two broad classes of attack that you need to defend against (it doesn't matter if Ajax is involved or not, its still the same type of API).
- Direct attacks - sanity check your data, don't let users edit things without authentication.
- Indirect attacks - in which a third party tricks a user into entering bad data (e.g. via a link on another site that asks their browser to make the HTTP request to your site). Defenses include things like requiring the client to request a one-use token before their can submit data (e.g. by generating a hidden input when the form is served up to stop third parties using their own form with malicious data and submitting users to your site with JS).
In a nutshell: Use the same defenses you would use if JS wasn't involved.