Display a message box in ASP.Net  3.5

Posted on 2009-02-12
Last Modified: 2012-05-06
I know this should be easy enough with javascript but i am failing miserably!
I want to display a choice message box to a user - Yes or No and continue on processing based on the button has clicked. It is not linked to the event of any control.

Can anyone help?

Question by:Cause
    LVL 36

    Expert Comment

    by:Loganathan Natarajan

    Author Comment

    Thanks loqudotcom. I don't have any event to link the javascript to. I am processing somecode and based on results i get back from the database i want to ask the user a question. if i understand the example correctly that it linked to an event. I just want to call it from
    LVL 13

    Expert Comment

    Just as discussed by logudotcom but in aspx

    <asp:Button  runat="server" ID="test" OnClientClick="return confirm('Are you sure?');" Text="Test" />
    LVL 13

    Assisted Solution

    If (your expresion to text)
         ClientScript.RegisterStartupScript(this.GetType(), "selectnodealert", @"<script type=""text/javascript"">confirm('please confirm ');</script>");

    LVL 44

    Accepted Solution

    Hello Cause,

    The simple answer is you can't simply stop your code-behind processing, throw a client-side message box and then continue processing just like that. You need to adapt the techniques already described and modify your behind-the-scenes processing to handle the fact that when you need to ask the question you need to end your processing script in the client-side message box, add a handler to this that responds to the option selected and then posts back to your code to continue (if appropriate) or cancel the existing processing.

    It is an oft-asked question but there is no way around breaking out of your code and back to the client-side.



    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now