Results 1 to 3 of 3

Thread: javascript yes/no instead of ok/cancel

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,475

    javascript yes/no instead of ok/cancel

    Is this true? it is not possible to change the content of the buttons in the dialog displayed by the confirm function

    This is my code to display a pop-up the our user to confirm his data:
    Code:
                Queue queue = (Queue)(handlerPages[HttpContext.Current.Handler]);
                if ((queue != null))
                {
                    StringBuilder builder = new StringBuilder();
                    int iMsgCount = queue.Count;
                    builder.Append("<script language='javascript'>");
                    string sMsg = string.Empty;
                    while ((iMsgCount > 0))
                    {
                        iMsgCount = iMsgCount - 1;
                        sMsg = System.Convert.ToString(queue.Dequeue());
                        sMsg = sMsg.Replace("\"", "'");
    
                        string[] QueueArray = sMsg.Split(',');
                        builder.Append("if(confirm( \"" + QueueArray[0] + "\" )) {");
                        builder.Append("location.replace('pageA.aspx?');");
                        builder.Append("} else {");
                        builder.Append("location.replace('pageB.aspx?');");
                        builder.Append("}");
                    }
                    builder.Append("</script>");
                    handlerPages.Remove(HttpContext.Current.Handler);
                    HttpContext.Current.Response.Write(builder.ToString());
                }
    The user wants to see Yes/No instead of OK/Cancel. It's true I can't use confirm?

    I did not write this code and I'll admit I don't understand it, so the first thing I will do is dissect it. But do I also have to rewrite it?

    Thanks.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: javascript yes/no instead of ok/cancel

    The javascript confirm method gives OK Cancel Button only. There is no default method by which you can Have YES / No button. Either you can go Jquery or Design a form which has YES/No button and call the form.

    Jquery Example here : http://jqueryui.com/dialog/#modal-confirmation

    And Another way here : http://forums.asp.net/t/1800080.aspx/1
    Please mark you thread resolved using the Thread Tools as shown

  3. #3

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,475

    Re: javascript yes/no instead of ok/cancel

    I believe we are going to use jquery. I will post the solution when it is complete. Thanks.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width