Window alerts in C#

the javascript way



if(error) //your logic here
{
  ClientScript.RegisterStartupScript(typeof(Page), "test", "<script>alert('Hello');return false;</script>");
}


to a button



btn.Attributes.Add("onClick", "javascript:alert('Message Here');");


using messagebox class (using System.Windows.Forms;)



if (MessageBox.Show("Do you want to continue?", "Question", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
//if user clicks yes, do stuff
}

or

System.Windows.Forms.MessageBox.Show("This is a message");


If errors should occur, go to project -> add reference,
then scroll down to System.Windows.Forms and select it.

This will add to web.config:

<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>


Ajax Modal Popup


http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx


Using Response on .Net Apps



Response.Write("<script type='text/javascript'>alert('This is my Message')</script>");


Using render objects


(HtmlWriter writer)

writer.Write("<script type='text/javascript'>alert('Hello');return false;</script>");

Comments

Popular posts from this blog

Breaking down document locking in SharePoint

Working around X-Frame-Options for iframes

Document ID not being generated