2
votes

How can I make my button ""input type="submit" value="Create" class="btn btn-default" " also redirect to another page(View) after submitting? Basically, I made a simple Form which sends email after that button click, and automatically returns me to Index page (default controller option(asp.net mvc core)), and i want to redirect it to another "Thank you for submitting an email" page(View).

4
Incorrect use of tags. Please refrain from using tags that have no meaning to the question. i.e. [css] tagLorddirt

4 Answers

2
votes

You forgot to add action='index.php' to your form tag.

e.g.

<form action='index.php'>
<input type='submit'/>
</form>

which gives a 404 error, because theres no such page as index.php

2
votes

// in PHP you can use

redirect('thank-you.php'); 
or 
header('location:thank-you.php');

/* function for redirect index or home page after some time you can write a setTimeout function in thank-you page.*/

<script>
  $(function(){
   setTimeout(function(){ window.location.href = "index.php"; }, 3000);
});
</script>

// I hope this is work for you.

1
votes

use action attribute inside form element that will redirect you to the page where you want it to be,

just you need to give the link or directory of that file or page or if you have created routing, then give route path according to the framework you are using this will help you for clear understanding

<form action="another_page.php"> <input type="text"> <button type="submit"> </form>

0
votes

you could use a return RedirectToPage("Thankyou");
as the return statement of your controller Action so that it redirects to a Thankyou.cshtml page.