Hi 65sametkaya65,
If you don't want to refresha the page make Ajax call to save the record in database.
For more details refer below article.
ASP.Net MVC: Insert Data to Database using jQuery AJAX
Refer the updated code.
<div class="w3-top" style="width: 85%">
<div class="w3-bar w3-red">
<a href="#" class="w3-bar-item w3-button">Masa-@ViewBag.frm</a>
@using (Html.BeginForm("GarsonCagir", "AnaMenu", FormMethod.Post))
{
<button class="btn btn-warning" id="ajax">Ajax</button>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script type="text/javascript">
$("body").on("click", "#ajax", function () {
var g = {};
g.masaid = $("#MASAID").val();
g.firmakodu = $("#FIRMAKODU").val();
g.garson = $("#GARSON").val();
$.ajax({
type: "POST",
url: "/AnaMenu/GarsonCagir",
data: JSON.stringify(g),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
alert("CustomerId: " + r.masaid);
}
});
});
$("body").on("click", '#ekle', function () {
Swal.fire({
title: "Good job!",
text: "You clicked the button!",
icon: "success"
});
})
</script>
<input type="text" name="MASAID" id="MASAID" value="@ViewBag.masaid" />
<input type="text" name="FIRMAKODU" id="FIRMAKODU" value="@ViewBag.firma" />
<input type="text" name="GARSON" id="GARSON" value="1" />
<input onkeyup="history.back()" type="submit" value="<<aa aa">
<button id="ekle" class="btn btn-danger">Garson Çağır</button>
}
<button style="background-color: black; color: white">Garson Çağır</button>
<button style="background-color: black; color: white" data-toggle="modal" data-target="#Modal1">Siparişi Gönder</button>
<input onclick="history.back();" type="button" value="<<geri dön">
<a href="/AnaMenu/Masa" class="btn btn-danger">Ana Sayfa</a>
</div>
</div>