【问题标题】:Best way of displaying a Message box or Confirmation box in ASP.NET在 ASP.NET 中显示消息框或确认框的最佳方式
【发布时间】:2012-11-04 06:53:32
【问题描述】:

大约一年以来,我每天都遇到对消息框的需求,我尝试了 jQuery 插件,JavaScripts alert 但仍然不确定哪种方式是最好的方式。

我想在 ASP.NET 页面(实际上是它的共享点应用程序页面)中显示一个消息框。

<%@ 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 I 中 必须开发/设计或使用大多数背后的消息框插件代码 时间(服务器端)例如在 C# 后面的 ASP.NET 代码中。现在我看到了 数十个问题要求,但实际上没有一个问题 根据最佳实践进行适当的解释。

【问题讨论】:

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


    【解决方案1】:

    您不能在服务器中引发 MessageBox。您必须编写代码,以便客户端 HTML+JS 在需要时发出警报。如果您需要一些确认页面,则需要构建页面并在用户按“是”或“否”时发布结果

    【讨论】:

    • 谢谢,但是为什么我不能在服务器中引发 MessageBox,我不需要确认页面,我想要一个漂亮的消息框,但我刚刚意识到我在页面加载功能中重定向,然后尝试使用 javascript 警报编写响应,但无论如何我想要一个 jquery 插件,我想我可以将重定向代码放在消息框中
    • 因为在服务器中运行的代码无法与 UI 交互(想象一下在数据中心中间的服务器中弹出一个 MessageBox :) 您只能生成客户端代码。
    • 啊哈,谢谢,但仍然对我想要做的事情感到困惑:)
    • 是的,我明白了。这是我开始 Web 开发时想到的第一件事。你想做什么?您想向用户显示什么信息?
    • 我在这里解释了更多stackoverflow.com/questions/13402297/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多