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

时间:2012-11-15 16:06:39

标签: c# asp.net sharepoint dialog custom-action

我遇到消息框的要求就像每天一样,大约一年后,我尝试了jQuery插件,JavaScripts警报,但我仍然不确定哪种方式是最佳方式。

我想在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\")");
    }

现在它不起作用,但它可能是一些语法错误但是如果我想显示一个正确的消息框(例如jquery的插件http://docs.jquery.com/UI/Dialog以一种它不刷新到页面的方式)什么我可以吗。

实际开发的是SharePoint文档库的自定义操作。

  

修改

     

我已经解释过的内容摘要是在SharePoint 2007中   必须开发/设计或使用最常见的消息框插件代码   时间(服务器端),例如在使用C#的ASP.NET代码中。现在我看到了   几十个问题要求,但他们实际上没有   根据最佳实践做出适当解释。

1 个答案:

答案 0 :(得分:2)

您无法在服务器中引发MessageBox。您必须编写代码,以便客户端HTML + JS在需要时引发警报。如果您需要一些确认页面,则需要构建页面并在用户按YES或NO

时将结果发回