当我单击关闭按钮时如何显示警报? [英] How to show an alert when i click on a close button?

查看:65
本文介绍了当我单击关闭按钮时如何显示警报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个包含4个字段和一个过滤器按钮的网页.
根据在文本框中输入的值,将生成报告.
该报告是网格视图.此报告包含问题.

当我单击报告中的任何问题时,它将向您显示该问题的所有详细信息,并带有关闭按钮.
当我单击关闭按钮时,它将关闭问题,(意味着它将从报告中删除问题).

现在的问题是我想在关闭按钮上放置一个警报,以便在问题关闭时显示警报.

我尝试了以下方法.

1)Response.Write(< script> alert(``问题已关闭''))</script>");

当我尝试此操作时,它向我显示警报消息,但我看不到屏幕背面.
警报弹出时,它向我显示白色空白页.

我已经尝试了以下javascript功能,但没有用.

Hi,

I have created a web page that contains 4 fields and a filter button.
Based on the values entered in the textboxes a report will be generated.
The report is a grid view.This a report that contains issues.

When I click on any issue in the report it will show you all the details of that issue it has a close button.
When I click on a close button it will close the issue,(means it will delete the issue from the report).

And now the problem is I want to put an alert on a close button so that it will show an alert when the issue is closed.

I have tried the following way.

1)Response.Write("<script>alert(''Issue has been closed'')</script>");

When I tried this it is showing me the alert message but I cannot see the screen backside.
It is showing me a white blank page when the alert pops out.

I have tried the following javascript funtion,but no use.

public static class Alert
{
/// <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);
}
}
}




有人可以帮我吗.
非常紧急.

在此先感谢




Can any one please help me regarding this .
Its very urgent.

Thanks in advance

推荐答案

使用这样的警报功能将脚本附加到aspx文件中

attach a script to your aspx file with an alert function like this

function ShowMessage(message)
{
   alert(message);
}

call the function on the clientclick event of the close button

<asp:button onclientclick="ShowMessage(''Issue will be deleted'')" xmlns:asp="#unknown">


您也可以尝试此操作以确认删除问题.

You can also try this for confirmation of delete issue.

<script language="JavaScript">
      <!--
            function confirm_delete()
            {
                  input_box=confirm("Are you sure you want to delete this issue?");
                  if (input_box==true)
                 {
                     // Output when OK is clicked
                      return true;
                  }
                  else
                  {
                       // Output when Cancel is clicked
                      return false;
                  }

            }
      -->
</script>



然后在关闭按钮的clientclick事件上调用该函数




And then call the function on the clientclick event of the close button


<asp:button onclientclick="return confirm_delete ()" xmlns:asp="#unknown">


希望 javascript-alert-window-closed-76659 [ ^ ]可能会为您提供帮助.
Hope javascript-alert-window-closed-76659[^] might help you.


这篇关于当我单击关闭按钮时如何显示警报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆