Alert with "yes" and "now" as button text

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kamiii
    New Member
    • Aug 2012
    • 8

    #1

    Alert with "yes" and "now" as button text

    Thank you very much , it worked! :)

    can you tell me If it is posible to change the 'ok' and 'cancel' to 'yes' and 'no' ???
  • ariful alam
    New Member
    • Jan 2011
    • 185

    #2
    @kamiii, what are you really want? can you Xplain please.

    Comment

    • kamiii
      New Member
      • Aug 2012
      • 8

      #3
      @ariful : thank you for your attention

      I want to change the ok buttun to yes or sth else
      I want to know is it possible or not?

      Comment

      • ariful alam
        New Member
        • Jan 2011
        • 185

        #4
        @kamiii, would you please text an example here what you are actually need to do.

        Comment

        • kamiii
          New Member
          • Aug 2012
          • 8

          #5
          look , I wanted to have a diolog box in order to check that if you are sure to delete an item or not.
          and by this code I could do that :

          Code:
          <asp:ImageButton ID="btnDelete" runat="server" OnClick="btnDelete_Click" ImageUrl="~/Images/icon/deletebuttonoff.png"
          CausesValidation="False" OnClientClick="return confirm('are u sure ?')" />

          it gives me a diolog box which I should click 'ok' or 'cancel'

          now I want to change this 'ok' to 'yes' , and 'cancel' to 'no'
          Last edited by gits; Aug 9 '12, 07:10 AM. Reason: added code tags

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            Please post new questions in their own threads. I split this question off of the thread Server Tag Not Well Formed and moved it into the JavaScript forum where it is more likely that the experts know how to achieve what you are looking for.

            -Frinny

            Comment

            • ariful alam
              New Member
              • Jan 2011
              • 185

              #7
              @kamiii, i don't think so. It may be not possible to change the Ok and Cancel button of Confirm Dialog to Yes and No button. You can create your own custom message box using buttons Yes and No in a div tag that may return a value true (for Yes) or false (for No).

              Comment

              • kamiii
                New Member
                • Aug 2012
                • 8

                #8
                @Frinavale : I didn't get it where should I search for yhis question exactly?!

                Comment

                • kamiii
                  New Member
                  • Aug 2012
                  • 8

                  #9
                  @ariful alam: but how?! I haven't any idea at all! :(
                  would you please tell me what should I do more specifically ?

                  Comment

                  • Frinavale
                    Recognized Expert Expert
                    • Oct 2006
                    • 9749

                    #10
                    What @ariful alam is suggesting is suggesting is getting rid of using the JavaScript alert/comfirm completely.

                    Instead you would have a <div> that would display your message and have 2 buttons "yes" and "no".

                    So, really your ImageButton would not submit anything to the server at all. When the user clicks the ImageButton, it would display the <div> that contains the message and the "yes" and "no" button.

                    The Yes button would be the thing that submit to the server...the No button would simply hide the <div>.

                    Something like this:
                    Code:
                    <div id="confirmSubmit" style="display:none; position:absolute; z-index:1; height:200px; width:200px;">
                      <div id="messageSection">
                        <p>Are you sure?</p>
                      </div>
                      <div id="buttonSection">
                        <asp:Button ID="userConfirmed" OnClick="btnDelete_Click" runat="server" Text="Yes" onclick="document.getElementByID('confirmSubmit').style.display='none'" />
                        <input type="button" onclick="document.getElementByID('confirmSubmit').style.display='none'">No</input>
                      </div>
                    </div>
                    Your ImageButton would execute some JavaScript to display the above <div>:
                    Code:
                    <asp:ImageButton ID="btnDelete" runat="server"  ImageUrl="~/Images/icon/deletebuttonoff.png"
                    CausesValidation="False" OnClientClick="document.getElementByID('confirmSubmit').style.display='block'; return false;" />
                    Make sure that the function signature for the btnDelete_Click method works for the Yes button.

                    If you don't want to use html <div> and want to stick to ASP.NET controls, you can use Panels like this:

                    Code:
                    <asp:Panel ID="confirmSubmit" runat="server" style="display:none; position:absolute; z-index:1; height:200px; width:200px;">
                      <asp:Panel ID="messageSection" runat="server">
                        <p>Are you sure?</p>
                      </asp:Panel>
                      <asp:Panel ID="buttonSection" runat="server">
                        <asp:Button ID="userConfirmed" OnClick="btnDelete_Click" runat="server" Text="Yes" onclick="document.getElementByID('confirmSubmit').style.display='none'" />
                        <asp:Button ID="userCanceled" runat="server" onClientClick="document.getElementByID('confirmSubmit').style.display='none'; return false;" Text="No" />
                      </asp:Panel>
                    </asp:Panel>

                    You can get quite fancy with this. You could display a <div> over top of the content of the page while your message box is displaying to prevent people from interacting with the page. You can style the div to match the look and feel of your website...You can use asp.net Labels and localize your message to fit the language of the user...you could add images or whatever you want to your message...You can do quite a bit with it!



                    -Frinny
                    Last edited by Frinavale; Aug 8 '12, 09:10 PM.

                    Comment

                    • Frinavale
                      Recognized Expert Expert
                      • Oct 2006
                      • 9749

                      #11
                      As to where to post questions...

                      If you have a question that is JavaScript related, ask it in the JavaScript forum where the experts have knowledge about the topic.

                      If you have an ASP.NET related question, ask it in the ASP.NET forum, where the experts have the knowledge about the topic.

                      Because ASP.NET is web related, your questions may span across both places...in which case, try to figure out which forum the experts might have more knowledge about the problem and post there :)

                      And try to limit yourself to 1 question per thread :)

                      -Frinny

                      Comment

                      • kamiii
                        New Member
                        • Aug 2012
                        • 8

                        #12
                        @Frinavale:

                        thank you very much Frinny :)
                        you spent so much time on my questions! thanks alotttt .....

                        and , ok , sure, I will do what you said about my later questions :)

                        Comment

                        Working...