[英]Calling Javascript function in C#
我如何能够在 C# 中的 Web 应用程序上向用户显示警报? 我试图通过调用我正在编写的 C# 中的 JS 函数来做到这一点,但我不确定如何这样做,因为 Page.ClientScript 未被识别。 我需要包含不同的命名空间吗?
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>");
}
.
.
.
这是一个很好的例子。 https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.clientscriptmanager?view=netframework-4.8
如果您想内联显示警报,也可以简单地使用以下方法:
Response.Write("<script>alert('hello');</script>");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.