I need some code in ASP.NET when Submit button Click show one messege Like "your Message Sent Successfully" in ASP.NET
I don't know ASP.net please anybody help me

Dani AI

Generated

wanted a simple confirmation after a form submit. 's quick client-side alert will work, but there are cleaner and more robust patterns depending on the scenario (full postback, UpdatePanel/AJAX, accessibility needs).

A plain server-side approach that works in every browser and is easy for beginners is to show an inline message with a Label. Place the Label in the page (initially hidden) and set its Text and Visible properties after processing the form. This avoids popups and is better for accessibility.

<!-- in .aspx -->
<asp:Label ID="lblStatus" runat="server" CssClass="success" Visible="false"></asp:Label>
/* in code-behind */
protected void Submit_Click(object sender, EventArgs e)
{
    // save/process data here
    lblStatus.Text = "Message submitted.";
    lblStatus.Visible = true;
}

If a client-side popup is preferred, use the ASP.NET client-script helpers rather than writing raw <script> tags. For full postbacks use ClientScript.RegisterStartupScript. If the page uses UpdatePanel/partial postbacks, use ScriptManager.RegisterStartupScript so the script is emitted correctly. See the Microsoft docs for details: ClientScript.RegisterStartupScript and ScriptManager.RegisterStartupScript.

Practical notes: prefer inline messages for better UX and accessibility; avoid blocking alerts in production; always validate on the server; disable the submit button to prevent double posts; and watch quoting/escaping when injecting JavaScript.

Recommended Answers

All 2 Replies

protected void Button1_Click(object sender, EventArgs e)
{
Page.RegisterClientScriptBlock("yourKey", "<script>alert('your message sent successfully');</script>");
}

Sounds a little like homework, no? Tsk tsk.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.