Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create a simple list of string in view, submitted from textbox, using submit button, without using model, using razor. I want that on every submit a new string in the list is created. I am trying the following code but it just creates one string in the list :-

What I have tried:

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<form action="" method="post">
    <p style="float:left;">Message: </p>
    <input type="text" name="message" style="float:left;" />
    <br /><br />
    <input type="submit" value="submit" />
</form>

@{ var message = "";
        if (IsPost)
        {
            message = Request["message"];
            <p> @message </p><br />

        }
    }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900