locked
Message Box to Show info in .CS class RRS feed

  • Question

  • User1808728899 posted

    Hi All,

             I have a class( .cs) which contains a function having try and catch block ,I am facing error and unable to display the message.As i don't get key word response.write to display message.Can  any one help me how can show meessage in pop-up box

    Friday, April 5, 2013 3:31 AM

Answers

  • User1508394307 posted

    samar anand

    it has some invalid arguments

    What exactly?

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
    <html>
    <head>
        <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    </form>
    </body>
    </html>
    using System;
    using System.Web.UI;
    
    namespace WebApplication1
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "AlertMessage", "alert('Test');", true);
            }
        }
    }

    Hope this helps.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 5, 2013 7:20 AM

All replies

  • User1508394307 posted

    string strScript = "<script language='javascript'>alert(\'" + Message+ "\');</script>"; 
    ScriptManager.RegisterStartupScript(this, this.GetType(), "PopupCP", strScript, false); 

    Friday, April 5, 2013 3:34 AM
  • User-1360095595 posted

    Use ClientScript.RegisterStartupScript() to register a simple alert() message. 

    Friday, April 5, 2013 3:35 AM
  • User1808728899 posted

    Hi  Metal,

               Thanks for your response.It is showing ClientScript  doesn't exist in current context

    Friday, April 5, 2013 5:41 AM
  • User1808728899 posted

    Hi Nov,

             Thanks for your response.When I use ScriptManager.RegisterStartupScript(this, this.GetType(), "PopupCP", errormsg.ToString, false);.Showing me error message it has some invalid arguments.

    Friday, April 5, 2013 5:43 AM
  • User1508394307 posted

    samar anand

    it has some invalid arguments

    What exactly?

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
    <html>
    <head>
        <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    </form>
    </body>
    </html>
    using System;
    using System.Web.UI;
    
    namespace WebApplication1
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "AlertMessage", "alert('Test');", true);
            }
        }
    }

    Hope this helps.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 5, 2013 7:20 AM
  • User-1360095595 posted

    samar anand

    Hi  Metal,

               Thanks for your response.It is showing ClientScript  doesn't exist in current context

    Ah yes. Ok. So you're calling this method from a Web page at some point, yes? So have the method return an error indicator/message and have the page do the alert. 

    Friday, April 5, 2013 7:24 AM
  • User1622294484 posted

    samar anand

    it has some invalid arguments

    What exactly?

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
    <html>
    <head>
        <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    </form>
    </body>
    </html>
    using System;
    using System.Web.UI;
    
    namespace WebApplication1
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "AlertMessage", "alert('Test');", true);
            }
        }
    }

    Hope this helps.

    Thanks , I used it and it worked .

    Sunday, April 7, 2013 4:26 AM