I wanted to make a website, but with a private section. The private section has to be accessed with a password. If I used a simple if statement to do so, will it be safe on the server side? Example:

Protected Sub AccessPrivate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles AccessPrivate.Click
        If InputBox("Enter password to unlock site:", "Password") = "password" Then
        End If
    End Sub

Would that be safe or would someone be able to view that source code?

No, you dont have to worry...asp.net is a server side scripting language. You can easily validate this by accesing the page via browser. Most browsers, if you right click from within the page, click on view source. You'll see that the code in the window is HTML.

The way it works when an asp.net page is called, the webserver processes your asp.net code, but will output HTML back to the browser. You see browsers are programmed to understand HTML, not asp.net, php, asp, java, etc...