Reputation: 107
How am I able to show an alert to the user on a Web Application in C#? I'm trying to do so by calling on a JS function within the C# I'm writing, but am unsure of how to do so since Page.ClientScript isn't being recognized. Do I need a different namespace included?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Transactions;
using System.Web.Http;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
.
.
.
while (physAuthToUpdate.start_date < physAuthToUpdate.end_date)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "print", "<script>showAlertWindow('Error: End date cannot come before begin date.');</script>");
}
.
.
.
Upvotes: 1
Views: 79
Reputation: 240
Here is a good example. https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.clientscriptmanager?view=netframework-4.8
And it may also be possible to simple use following if you want to show the alert inline:
Response.Write("<script>alert('hello');</script>");
Upvotes: 0