0

I'm trying to make a simple crud. Here's my html:

<html>
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server" method="post" 
    action="home.aspx">
        <div>
            <input runat="server" id='txtName' type='text'/>
            <button runat="server" id='btnSubmit' 
            onserverclick="add">Submit</button>
            <p runat="server" id="list"></p>
        </div>
    </form>
</body>
</html>

After clicking the button, it does work but I think the array resets itself.

<script runat="server">
    ArrayList names = new ArrayList();
    string listing = "";
    private void add(object sender, EventArgs e)
    {
        string name = txtName.Value;
        names.Add(name);
        for(int i = 0; i < names.Count; i++)
        {
            listing=listing + names[i]+ " ";
            list.InnerHtml = listing;
        }
    }
</script>
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
ChaChaCha
  • 35
  • 5
  • SO is not the place to learn wide ranging concepts - recommend this -> https://dotnet.microsoft.com/en-us/learn/aspnet – jazb Apr 05 '22 at 01:45
  • For future questions please avoid "new here", "new to language/concept", "thank you in advanced" and all other sorts of text unrelated to the question. Please review https://meta.stackoverflow.com/questions/288160/no-thanks-damn-it – Alexei Levenkov Apr 05 '22 at 01:49

0 Answers0