How to change HTML text with a function in c#

Viewed 39

I'm currently learning to work with api's and asp.net, but i still have a few problems, namely the connection between the c# and HTML is still a thing, therefore this problem which I can't figure out. How do I change text based on C# code?

HTML:

 <form action="/action_page.php">
        <label for="name">Insert Name:</label><br>
        <input type="text" id="name" name="name"><br>
        <input type="submit" value="Submit">
    </form>
    <p>this text will change to the input of the textbox if the button is pressed</p>

C#

namespace hopeThisWorks
{
    public class Code
    {
        public string showName(string name/*this is supposed to be the text from the textbox*/)
        {
            return name;
        }
    }
}

I know that what I'm trying to achieve with this code is easily done with a little JS, but more complicated code will fill in the C# portion of the code, therefore this simple notation. So how do I send the request to C# from the button?

0 Answers
Related