1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

messagebox.show in asp.net

Discussion in 'C#' started by progfrog, May 28, 2008.

  1. #1
    Hi guys,

    I have an urgent question:

    i built a form in html and past it to an aspx file.
    After that i went to aspx.cs and added a button , it should make a messegebox to appear after the onclick event in cs.

    there are two problems: the first: the messegebox doesn't appear after the button has been cliked . the second: how come the cs file doesn't recognize the controls i made in html? how can i manipulate the data from my text fields to other controls in cs...

    thanx a lot and this is the code in cs:


    
    
    
    public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void FormGO_Click(object sender, EventArgs e)
        {
            messegbox.show("plain text");/// it isn't recognizeble to the compiler
        }
    }
    
    
    
    
    
    Code (markup):
    and this is the code from aspx file:
    
    
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
       
        <input type="text" id="FirNam"/>
            <input type="text" id="SurNam"/>
          
            <asp:Button ID="FormGO" runat="server" Text="Button"  OnClick="FormGO_Click" />
           
           
           
           </form>
            </body>
            
    
    
    Code (markup):
    :(:)
     
    progfrog, May 28, 2008 IP
  2. vpguy

    vpguy Guest

    Messages:
    275
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Could it be the misspelling of messagebox? Or perhaps it should be MessageBox.Show("plain text");?

    Nearly everything in C# is UpperCamelCase.
     
    vpguy, May 28, 2008 IP
  3. progfrog

    progfrog Peon

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    when i start writeing the word m the program usually uses the autocomplicity and gives the list of the objects and method that are relevent but this isn't the case..

    is there anything else that can be possible?
     
    progfrog, May 28, 2008 IP
  4. entwickler

    entwickler Member

    Messages:
    74
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    entwickler, May 28, 2008 IP
  5. hajan

    hajan Peon

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Why not? I think you guys are wrong... You can use MessageBox.Show("text") in ASP.NET Web forms, but firstly you have to put using System.Windows.Forms;

    It can be used for example like in the following way:
    if (MessageBox.Show("Are you sure you want to proceed?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
    {
    MessageBox.Show("You have clicked YES")
    // do some more actions
    }
    else { MessageBox.Show("You have clicked NO") }
     
    hajan, Dec 16, 2008 IP
    islandhopper8 likes this.
  6. islandhopper8

    islandhopper8 Active Member

    Messages:
    100
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    73
    #6
    Yea like hajan said it works.

    The messagebox shows in Firefox and IE.

    However if you have two screens and you show the website on the second screen the message box pops up on the first screen.
     
    islandhopper8, Dec 20, 2008 IP
  7. vihutuo

    vihutuo Well-Known Member

    Messages:
    1,511
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #7
    MessageBox.Show() will only work when you are using visual studio .... It will not work once you deploy the application , you will need to use client side code
     
    vihutuo, Dec 21, 2008 IP
  8. hajan

    hajan Peon

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Yes. The MessageBox.Show() will work but won't be shown to the user if the application is deployed because it will prompt and show up only in the Server, so the user (Client side) won't see it at all.

    This occurs because as I said previously, MessageBox.Show() uses 'using System.Windows.Forms;' ... so won't work on ASP.NET Applications when deployed.
    Instead, you can use JavaScript.
     
    hajan, Dec 22, 2008 IP
  9. mpatel

    mpatel Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    yes you can display messagebox in the asp.net you need to use or include "using System.Windows.Forms;" before it ypu have to add refernce by right click on the projct and the from option"Add reference"and the add System.Windows.Forms then you can get result.
     
    mpatel, Dec 24, 2008 IP
  10. rajendra.parmar

    rajendra.parmar Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    You try,

    Response.write() function instead of MessageBox.Show().

    MessageBox.Show() will not work in the web development...
     
    rajendra.parmar, Jan 2, 2009 IP
  11. seo_specialist

    seo_specialist Guest

    Messages:
    106
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    MessageBox.Show() this very old one and specially used for vb, but here needed client side code ....
     
    seo_specialist, Jan 5, 2009 IP
  12. tabish8612

    tabish8612 Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    replace messageboxshow with msgbox
    if u want to display only text

    format is
    msgbox"text"
     
    tabish8612, Jan 5, 2009 IP
  13. hajan

    hajan Peon

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #13
    For client side code.. I have another good method... If you have ASP Button Server Control... You can add attributes to this button with JavaScript client-side code..
    Something like the following code:
    In progfrog case we have:
    <asp:Button ID="FormGO" runat="server" Text="Button" OnClick="FormGO_Click" />

    Just remove this OnClick="FormGo_Click"
    <asp:Button ID="FormGO" runat="server" Text="Button" />

    and in your code-behind the page (C# or VB.NET) add:
    (C#)
    FormGo.Attributes.Add("onclick", "javascript:if(confirm('Are you sure?')==true) return true;");

    I think using this code, you will implement complete client side validation with MessageBox and asking the user to proceed with CLICKING THE BUTTON or NOT... ;)

    Try it.. u will find it useful ;)
     
    hajan, Jan 12, 2009 IP
  14. ppce

    ppce Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    just use bestcontactform.com. :)
     
    ppce, Apr 6, 2012 IP
  15. Michael Brown

    Michael Brown Peon

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Use alert() function in Javascript
     
    Michael Brown, Apr 12, 2012 IP
  16. raspms

    raspms Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    such a interesting posting...
     
    raspms, Apr 17, 2012 IP
  17. Scarrfo

    Scarrfo Peon

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Scarrfo, May 5, 2012 IP