Q:

How Do I Use C# Code In HTML To Get ID Out Of A SQL Database?

So I'm trying to create a website with a database and currently just wanting to check the database connnection by printing a number from the database in the HTML code. I'm terrible at scripts so please ignore that.
The C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
public class LogFiller
{
    public int userID;
    string connectionstring = "USER ID=x;" +
                                       "PASSWORD=x;server=x;" +
                                       "Trusted_Connection=yes;" +
                                       "database=x; " +
                                       "connection timeout=30";

    public LogFiller()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public int getUserID
    {
        get {

            using (var connection = new SqlConnection(connectionstring))
            {
                try
                {
                    connection.Open();

                    SqlCommand myCommand = new SqlCommand("SELECT ID FROM x WHERE Name = 'x'", connection);
                    SqlDataAdapter adapter = new SqlDataAdapter(myCommand);
                    DataTable dt = new DataTable();
                    adapter.Fill(dt);

                    return (int)dt.Rows[0][0];
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }

            return userID;
        }
    }
}

The script I thought of (but doesn't work)
@{ 
    LogFiller lf = new LogFiller();
    lf.getUserID;
}

For clarification: I want to just write the number that the C# code returns anywhere on my page.

A:

Once you open a C# block with the @{ }, in order to write the value from a variable inside that block you need to escape it with another @ like this:
@{
   LogFiller lf = new LogFiller();
   <p>User ID: @lf.getUserID</p>
}

Also, as someone in a comment stated, you'll likely need to fully qualify your LogFiller type with the namespace. So WhateverYourNamespaceIs.LogFiller

