How to Display Message Box on Screen while using Asp.net with C# ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • todashah
    New Member
    • Feb 2008
    • 26

    How to Display Message Box on Screen while using Asp.net with C# ?

    Hi ! Guys,
    I have no idea about How to Display Message Box on Screen while using Asp.net with C# ? Help Me.
    Thanks in advance...
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Can't do it with ASP.NET. Remember, ASP.NET is a Server Side technology. Javascript is really your only hope.

    There is a way to get confirmation on a button press, though. I'm not sure if it is what you need, but here it is if it helps you.
    Code:
    <!-- aspx file -->
    <asp:Label ID="lConfirmed" runat="server" Text="Not Confirmed" /><br />
    <asp:Button ID="bConfirm" runat="server" Text="Confirm?" 
    	OnClientClick="return confirm('Are you sure?');"
    	OnClick="bConfirm_Click" />
    Code:
    //.aspx.cs file
    protected void bConfirm_Click(object sender, EventArgs e)
    {
    	lConfirmed.Text = "Confirmed";
    }
    This will run the javascript in the OnClientClick, and if it returns true, run the server code. Else, cancel the postback.

    Comment

    Working...