简体   繁体   English

在 ASP.NET 中显示消息框或确认框的最佳方式

[英]Best way of displaying a Message box or Confirmation box in ASP.NET

I came across requirement for message box like everyday since around a year now, I tried jQuery plugins, JavaScripts alert but am still not sure which way would be the best way of doing it.大约一年以来,我每天都遇到对消息框的需求,我尝试了 jQuery 插件、JavaScripts 警报,但仍然不确定哪种方式是最好的方式。

I want to display a message box within ASP.NET Page (well its actually sharepoint application page).我想在 ASP.NET 页面中显示一个消息框(它实际上是 sharepoint 应用程序页面)。

<%@ Page Language="C#" MasterPageFile="~/_layouts/abc/simple.master"  Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" %>
<%@ Assembly Name="Microsoft.SharePoint.ApplicationPages, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%> 
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="System" %>

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        string a= aa(Request.UrlReferrer.ToString());
        string b= bb(Request.UrlReferrer.ToString());

        mm(a, b);

        Uri uu= Request.UrlReferrer;
        if (uu!= null)
            Response.Redirect(uu.ToString());

        System.Web.HttpContext.Current.Response.Write("alert(\"write here what you want\")");
    }

Now it doesn't work but it could be some syntax error but what If I want to display a proper message box(eg jquery's plugin http://docs.jquery.com/UI/Dialog in a way that it doesn't do refresh to page) what can I do.现在它不起作用但它可能是一些语法错误但是如果我想显示一个正确的消息框(例如 jquery 的插件http://docs.jquery.com/UI/Dialog以它不做的方式)刷新到页面)我能做什么。

what am actually developing is a Custom Action for SharePoint Document Library.我实际开发的是 SharePoint 文档库的自定义操作。

EDIT编辑

Summary of what I already explained is in SharePoint 2007 I have to develop/design or use message box plugins code behind most times (server-side) eg in ASP.NET code behind with C#.我已经解释过的摘要是在 SharePoint 2007 中我必须在大多数时候(服务器端)开发/设计或使用消息框插件代码,例如在 C# 后面的 ASP.NET 代码中。 Now I seen tens of question asking for that but non of them are actually giving a proper explanation in accordance to best practices.现在我看到了数十个问题要求这样做,但实际上没有一个问题根据最佳实践给出了正确的解释。

You can't raise a MessageBox in the server.您不能在服务器中引发 MessageBox。 You must write the code so the client HTML+JS raise the alert when needed.您必须编写代码,以便客户端 HTML+JS 在需要时发出警报。 If you need some confirmation page, you need to build the page and post the results back when the user press YES or NO如果您需要一些确认页面,您需要构建页面并在用户按 YES 或 NO 时将结果发回

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM