Successful after the button

Harun Ergün 65 Reputation points
2023-01-19T05:44:16.66+00:00

I want to see the text Alert (Successful) after the button is clicked. How should I do ?

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,250 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,679 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 25,471 Reputation points Microsoft Vendor
    2023-01-19T06:19:04.3666667+00:00

    Hi @Harun Ergün,

    When you ask a question, it is best to describe it in more detail, such as what project you want to implement.

    According to your previous question, I think you are implementing it in Asp.Net MVC.

    You can refer to the example below.

    @{
        Layout = null;
    }
    
    <!DOCTYPE html>
    
    <html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>Index</title>
    </head>
    <body>
        @using (Html.BeginForm("Index", "Home", FormMethod.Post))
        {
            <input type="text" id="txtName" name="name" />
            <input type="submit" id="btnSubmit" value="Get Current Time" />
        }
        @if (ViewBag.Message != null)
        {
            <script type="text/javascript">
                window.onload = function () {
                    alert("@ViewBag.Message");
                };
            </script>
        }
    </body>
    </html>
    
     // GET: Home
            public ActionResult Index()
            {
              
                return View();
            }
    
            [HttpPost]
            public ActionResult Index(string name)
            {
                ViewBag.Message = "success";
                return View();
            }
    

    1

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful