my requirement--- when i click button message box should be displayed in web form
Message Box
How to create a Message box in a.s.p.net?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jul 29, 2013, 9:25 AM EDT
you can try following code. it will show a message on button click
ex:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
if any doubt or problem reply
Akhil MittalRank #133 · 16.9K reputationPosted Jul 29, 2013, 7:56 PM EDT
///
/// A JavaScript alert///
public static class Alert
{///
/// Shows a client-side JavaScript alert in the browser.///
/// The message to appear in the alert.
public static void Show(string message)
{// Cleans the message to allow single quotation marks
string cleanMessage = message.Replace("'", "\\'");string script = string.Format("", cleanMessage);
// Gets the executing web page
Page page = HttpContext.Current.CurrentHandler as Page;
// Checks if the handler is a Page and that the script isn't all ready on the Page
if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("alert"))
{
page.ClientScript.RegisterClientScriptBlock(typeof(Alert), "alert", script);
}
}
}
http://www.c-sharpcorner.com/Blogs/12168/javascript-alert-in-C-Sharp.aspx
Mark as Accepted if it helps u.
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 29, 2013, 8:00 PM EDT
Try like this
if you don't want to submit the page after clicking the button return false otherwise removed this line.
Regards,
Iftikar
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 29, 2013, 8:00 PM EDT
Try like this
if you don't want to submit the page after clicking the button return false otherwise removed this line.
Regards,
Iftikar
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 29, 2013, 8:00 PM EDT
Try like this
if you don't want to submit the page after clicking the button return false otherwise removed this line.
Regards,
Iftikar
Keyur PatelRank #1,216 · 1.5K reputationPosted Jul 30, 2013, 11:15 PM EDT
I think, i am bit late in this thread. I would suggest first to user Javascript alert function to use in your web form to display your alert as suggested by users in this forum.
If you do not want to use Javascript Alert function then you can use external Win32 dll Methods and invoke Message Box method same as we are using in Window form but i would not suggest to use this option.
Please find the attached sample to display MessageBox same like in window form.
Mark as Accepted if it helps you.