Я читаю этот JavaScript: Alert.Show (сообщение) Из кода ASP.NET
Я пытаюсь реализовать то же самое. Итак, я создал статический класс, как это:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Text;
using System.Web.UI;
namespace Registration.DataAccess
{
public static class Repository
{
/// <summary>
/// Shows a client-side JavaScript alert in the browser.
/// </summary>
/// <param name="message">The message to appear in the alert.</param>
public static void Show(string message)
{
// Cleans the message to allow single quotation marks
string cleanMessage = message.Replace("'", "\'");
string script = "<script type="text/javascript">alert('" + cleanMessage + "');</script>";
// Gets the executing web page
Page page = HttpContext.Current.CurrentHandler as Page;
// Checks if the handler is a Page and that the script isn't allready on the Page
if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("alert"))
{
page.ClientScript.RegisterClientScriptBlock(typeof(Alert), "alert", script);
}
}
}
}
На этой линии:
string script = "<script type="text/javascript">alert('" + cleanMessage + "');</script>";
Это показывает мне ошибку :; ожидаемый
А также на
page.ClientScript.RegisterClientScriptBlock(typeof(Alert), "alert", script);
Err: Тип или имя пространства имен 'Alert' не может быть найдено (вам не хватает директивы using или ссылки на сборку?)
Что я здесь не так делаю?