问题
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.
I want to display a message box within ASP.NET Page (well its actually sharepoint application page).
<%@ 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(e.g. jquery's plugin http://docs.jquery.com/UI/Dialog in a way that it doesn't do refresh to page) what can I do.
what am actually developing is a Custom Action for SharePoint Document Library.
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) e.g. in ASP.NET code behind with C#. Now I seen tens of question asking for that but non of them are actually giving a proper explanation in accordance to best practices.
回答1:
You can't raise a MessageBox in the server. You must write the code so the client HTML+JS raise the alert when needed. If you need some confirmation page, you need to build the page and post the results back when the user press YES or NO
来源:https://stackoverflow.com/questions/13401491/best-way-of-displaying-a-message-box-or-confirmation-box-in-asp-net