how we get pop up message in .net

Posted by Manbkp under ASP.NET on 8/7/2013 | Points: 10 | Views : 4813 | Status : [Member] | Replies : 6
hi , i m using code to get popup message in .net. please provide other codes to get popup message in web application.
My code is ---
ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Sucessfully added')</script>");




Responses

Posted by: Learningtorise on: 8/7/2013 [Member] Starter | Points: 25

Up
0
Down
If ClientScript.RegisterStartupScript not working then try ClientScript.RegisterClientScriptBlock .

It should work!

http://hashtagakash.wordpress.com/

Manbkp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 8/7/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Alternatively you can use AJAX ModalPopupExtender to show PopUps in Web applications. Refer the following link to know the usage of ModalPopupExtender.
http://www.aspdotnet-suresh.com/2011/12/ajax-yesno-button-options-customized.html

By using ClientScript.RegisterOnSubmitStatement
-- On page load
protected void Page_Load(object sender, EventArgs e)

{
string message = "Do you want to Submit?";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("return confirm('");
sb.Append(message);
sb.Append("');");
ClientScript.RegisterOnSubmitStatement(this.GetType(), "alert", sb.ToString());
}


Using ClientScript.RegisterClientScriptBlock
// on Button click
protected void Button1_Click(object sender, EventArgs e)

{
string message = "Order Placed Successfully.";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload=function(){");
sb.Append("alert('");
sb.Append(message);
sb.Append("')};");
sb.Append("</script>");
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
}


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Manbkp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 8/7/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace WebApplication16
{
public partial class WebForm9 : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = TextBox1.Text;
ClientScriptManager csm = Page.ClientScript;
csm.RegisterStartupScript(this.GetType(), "showalert", "alert('Data Saved Successfully.')", true);
}
}
}


If this post helps you mark it as answer
Thanks

Manbkp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: aswinialuri-19361 on: 8/7/2013 [Member] Starter | Points: 25

Up
0
Down
HI,
try this it might be helpful to you
Response.Write("<script>alert('your data dded successfully')</script>");

Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Manbkp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 8/7/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
The other way to show popup is as follows:-

protected void Page_Load(object sender, EventArgs e)
{
Button1.Attributes.Add("onclick", "javascript:alert('Data Saved Successfully.')");
}

Happy coding.

Manbkp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rimi1289 on: 8/10/2013 [Member] Starter | Points: 25

Up
0
Down
U need to understand how to call JavaScript functions from Code Behind.
http://www.encodedna.com/2012/11/call-javascript-codebehind.htm

Since pop up messages are fired at the client side, so you need to a client script which show the message.

Manbkp, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response