73045

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

Question:

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 <a href="http://docs.jquery.com/UI/Dialog" rel="nofollow">http://docs.jquery.com/UI/Dialog</a> 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.

<blockquote>

<strong>EDIT</strong>

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.

</blockquote>

Answer1:

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

Recommend

  • File Folder copy
  • Google Maps V3 Using Reimer ASP.NET Control
  • Maintaining page number in DropDownList after postback to refresh server timeout
  • How to run off ASP.NET validation for aspx in VS?
  • Display image from path in imageView in ios [duplicate]
  • AJAX not working in ASP.NET
  • User control property set in code front is null in OnPreRender
  • System.IO.FileNotFoundException: Could not load assembly office. perhaps doesn't exist in the M
  • using rich textbox in Sharepoint 2013
  • Another assembly referencing the old dll
  • Azure Bot Framework Emulator Error - System.ArgumentNullException: Value cannot be null
  • Target the XNA framework in ordinary Visual Studio 2012 project
  • Using curl with Phalanger
  • VS2013 Build Definition 'Microsoft.TeamFoundation.Client.BasicAuthCredential' is not marke
  • Robotium & system dialogs
  • Entity Framework on SQL Server CE without driver install
  • Gephi's java default method not implemented in C# with an ikvm-from dll library
  • How does the scala compiler locate the positions for variance annotation
  • Activation error occured while trying to get instance of type LogWriter, key “”
  • Raise Session_OnStart event from custom ASP.NET SessionStateProvider class
  • How to load a CascadeClassifier using Emgu c#
  • Need help to stop program terminating without users consent
  • PHP Handling Namespace with SimpleXML
  • Finding All Combinations (cartesian product) of list values in vb.net
  • How to add System.Windows dll to Visual Studio 2010 express?
  • DependencyObject.AssociatedObject is always null
  • C++ Coin flip program error
  • string.IsNullOrEmpty() Doesn't Seem to Work on a String within a Class within a Class
  • Curried UDF - Pyspark
  • jersey/tomcat Description The origin server did not find a current representation for the target res
  • Magento get URL before current
  • WPF Template Binding in ToggleButton UserControl
  • Installing iPhone App to iPhone
  • Matplotlib draw Spline from multiple points
  • Why winpcap requires both .lib and .dll to run?
  • Return words with double consecutive letters
  • Python: how to group similar lists together in a list of lists?
  • Checking variable from a different class in C#
  • Busy indicator not showing up in wpf window [duplicate]