First of all, I'm new to web development, so forgive me for this newbie question.
I have 4 inputs on my View, which I would like to send to my controller when a button is pressed.
<input type="text" name="title" />
<input type="text" name="description" />
<input type="text" name="link" />
<input type="date" name="date" />
And here is my ControllerMethod:
public ActionResult AddNewsToList(string title ="a", string description = "b", string link = "c", string pubDate = "01-02-2016")
{
Models.RssWriter.createNewsItem(title, description, link, pubDate);
return View("News", NewsFeed.Models.RssReader.GetRssFeed());
}
So can anyone guide me to making a button that can do this for me? Thanks for reading.
EDIT
This is how it actually looks like right now:
CreateNews.cshtml
@using (Html.BeginForm("AddNewsToList"))
{
<table>
<tr>
<th>
Titel
</th>
<tr>
<td>
<input type="text" name="title" />
</td>
<tr>
<th>
Beskrivelse
</th>
<tr>
<td>
<input type="text" name="description" />
</td>
<tr>
<th>
Link
</th>
<tr>
<td>
<input type="text" name="link" />
</td>
<tr>
<th>
Udgivelsesdato
</th>
<tr>
<td>
<input type="date" name="date" />
</td>
<tr>
<td>
<br />
</td>
</table>
<input type="submit" id="AddNewsToList" name="AddNewsToList" value="Tilføj" />
}
But this does not seem to work.