displaying a messagebox.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gopal Sharma akki
    New Member
    • Sep 2010
    • 4

    displaying a messagebox.

    Code:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if ((TextBox1.Text == "gopal") && (TextBox2.Text == "smile"))
            {
                Response.Redirect("Default2.aspx");
            }
            else
            {
                MessageBox.Show("Invalid Username and Password combination");
            }
        }
    }
    this messagebox gives an error that messagebox does not found in current context.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Be sure to add the namespace reference to classes you use:
    using System.Windows. Forms;

    EDIT: Oops this is a webpage? That messagebox will popup on the server, not on the client.
    Backend code is only executed on the server.

    You would need to use the javascript alert() function to popup a message on the client

    Comment

    • Gopal Sharma akki
      New Member
      • Sep 2010
      • 4

      #3
      displaying a messagebox

      i m using VBScript as a scripting language.
      after using namespace System.Windows. Forms; it gives an error that the namespace name 'Windows' does not exists in the namespace 'System'(are you missing an assembly refrence?).

      Comment

      • mzmishra
        Recognized Expert Contributor
        • Aug 2007
        • 390

        #4
        try something like this

        string script =" MsgBox 'Invalid Username and Password combination'";
        Page.RegisterSt artupScript("me ssage", "<script language=\"VBSc ript\">" + script + "</script>");

        Comment

        Working...