ConfirmButtonExtender + Text Formatting

Rate It (1)

Last post 08-23-2007 1:10 AM by jmckeand. 18 replies.

Sort Posts:

  • ConfirmButtonExtender + Text Formatting

    04-24-2006, 8:53 AM
    • Participant
      1,526 point Participant
    • James_2JS
    • Member since 02-13-2006, 3:21 PM
    • Posts 335

    Hi!

    I often need to have some quite long confirmation messages for user actions, and would normally achieve this by formatting the ConfirmText string using \t and \n in my javascript to achieve this. For example,

    confirm('Are you sure you want to do this?\n\nThe consequences of this action are:\n\t1) xxx\n\t2) yyy')

    When using this sort of technique with the ConfirmButtonExtender, the \n and \t are escaped and rendered as is!

    Is there any way to add put this control characters into the text??

    Thanks,

    James

  • Re: ConfirmButtonExtender + Text Formatting

    04-24-2006, 3:14 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842
    • AspNetTeam
    Have you tried changing ConfirmButton.js's this._onClick method to unescape the string before displaying it? (Perhaps with JavaScript's regex functionality?)

    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: ConfirmButtonExtender + Text Formatting

    04-25-2006, 5:08 AM
    • Participant
      1,526 point Participant
    • James_2JS
    • Member since 02-13-2006, 3:21 PM
    • Posts 335

    Hi David,

    No I haven't tried that, but to be honest, it's not really a route I want to go down... while it would work perfectly well, I don't think that it is something that I can rely upon for future versions of the toolkit...

    If this is considered a bug that will be fixed in future versions, then it's worth making the change, but if not, I will be stuck with a solution that could have a limited lifespan once we no longer have access to the .js files! Big Smile [:D]

    Cheers,

    James

     

  • Re: ConfirmButtonExtender + Text Formatting

    04-25-2006, 5:16 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842
    • AspNetTeam
    As far is I know, the Toolkit and its source will always remain free to users. I'd say that you should feel free to make changes like this. I'm undecided on whether or not to declare this a bug in the Toolkit. I'm a little afraid of getting into escaping here if it's not something that lots of people will want (I'm considering the added complexity vs. the value). If I hear from a few others that unescaping is desired (feel free to reply to this post), I'll log a bug to fix this. Thanks!

    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: ConfirmButtonExtender + Text Formatting

    04-26-2006, 9:28 AM
    • Participant
      1,526 point Participant
    • James_2JS
    • Member since 02-13-2006, 3:21 PM
    • Posts 335
    Thanks for this David... here's my view on it:

    1) Anyone currently trying to do a confirm box without the toolkit would expect to escape their strings as they would be using Javascript... Surely the extender should allow you to achieve this same functionality out of the box?
    ! Idea [Idea]

    2) Isn't the purpose of the Toolkit to make life easier... not more difficult!!! Smile [:)]

    3) As soon as someone needs to have a long string to display it is going to look pretty ugly without some formatting

    4) I'm sure that this isn't going to be the only release of the toolkit... I personally don't want to be having to patch the toolkit every time a new version is released... and my boss wouldn't be happy using technology that requires a manual patch every time either... and it doesn't look great telling other developers in the department that in order to maintain my source code they have to download a toolkit and make changes to it straight away!!

    5) If the toolkit ends up being like the rest of Atlas, the .js files will eventually get packaged up and not available for editing. Although you will be more in the know than I am, I'm just being realistic!! Wink [;)]

    Just my opinion, but I would really appreciate it if this was considered a bug!!

    I would much prefer to use the toolkit as it seems the right way to go from a design point of view, but having to make changes to it is less attractive than adding 

    OnClientClick="return confirm('Text\n\nMore Text');"
     Regards,

    James
  • Re: ConfirmButtonExtender + Text Formatting

    04-26-2006, 2:24 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842
    • AspNetTeam
    Okay, you win. :) I've added a note to try to address this in the next release. Thanks for the follow-up!

    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: ConfirmButtonExtender + Text Formatting

    04-26-2006, 3:47 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842
    • AspNetTeam

    We discussed this issue at some length just now. There were a couple of different viewpoints, but ultimately we all agreed on a solution we like.

    The problem with modifying the .js behavior itself (as I was initially planning to do) is that we introduce JavaScript/C# conventions ('\n' -> new line) into a .ASPX page that may be written in VB (or some other language). This could be confusing for page authors. Additionally, we'd have to choose exactly what escapes to support and that choice could be kind of arbitrary.

    Instead, the proposal was to let the page author make the necessary change in the language of their choice by having them modify the OnLoad member of their page to override the ConfirmText property of the relevant ConfirmButton control(s). It's not quite as seamless, but it has the benefits that a) it works in the page's programming language, b) you can make the change with the current release, and c) you never need to make the change again even as we release new Toolkits. Sounds good, huh?

    An example of this technique in action:

    I added the following to ConfirmButton.aspx.cs to add the appropriate new line characters:

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        ConfirmButtonExtender1.GetTargetProperties(Button1).ConfirmText = "Are you sure you want to do this?\n\nReally sure???";
    }

    And, to avoid confusion, changed ConfirmButton.aspx from:

            <atlasToolkit:ConfirmButtonProperties TargetControlID="Button1" ConfirmText="Do you have any idea what this button does?" />

    To:

            <atlasToolkit:ConfirmButtonProperties TargetControlID="Button1" ConfirmText='[Set by ConfirmButton_ConfirmButton.OnLoad]' />

    That's it! The result is a confirm dialog with new line characters just like you'd expect. Hope you like it!!


    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: ConfirmButtonExtender + Text Formatting

    04-27-2006, 5:34 AM
    • Participant
      1,526 point Participant
    • James_2JS
    • Member since 02-13-2006, 3:21 PM
    • Posts 335
    Hi David,

    Thanks for this, however I'm still having problems with implementing this in my situation:

    • I have my Button and ConfirmButtonExtender embedded deep within a EditItemTemplate within a TemplateField in a GridView inside a Wizard!!
    • I can add an OnLoad property to the ConfirmButtonExtender, but am not sure how to get a handle to the Button to pass into GetTargetProperties.
    • I am writing several lines of code, but still not achieving my goals!! (Probably because I cannot guarantee that the controls exist when the events fire??Confused [*-)]
    OK... so let's assume you can help me with the appropriate code to get handles to all my controls to set the property correctly... I still don't like the solution for the following reason:

    • Isn't one of the major design goals with .NET to separate application functionality from application design??
    • Aren't we trying to achieve a situation where a site designer can come along, not knowing how to code, and change the look and feel of the site without having to edit code? If I make a typo in the confirm box or the text needs changing for some reason (e.g. changes to government legislation), we want to be in a position where expensive development resource is not required to make the change!
    At the end of the day, it is currently much easier for me to add the property 
    OnClientClick="return confirm('Text\n\nMore Text');"
    to my Button rather than jumping through hoops to use an extender that is supposed to make life easier!!!!

    Sorry to be a pain, and thanks for all your help so far!

    Regards,

    James


  • Re: ConfirmButtonExtender + Text Formatting

    04-28-2006, 7:24 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842
    • AspNetTeam
    I hear you. I'm running another idea by folks to see if they like that any better...

    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: ConfirmButtonExtender + Text Formatting

    05-01-2006, 8:08 PM
    Answer
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842
    • AspNetTeam

    James,

    I think I've got something you'll like: HTML Entities! If you're not familiar, you can see a little chart here: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/charsets/charset1.asp. Of particular interest to us in this case is "&#10;", decimal value 10, which corresponds to the '\n' character. Changing the sample string to "Do you have any idea what this button does?&#10;&#10;Really??" results in a confirm dialog with a blank line just like you want. The great thing about this approach is that it encodes the formatting in the language of the ASPX page itself, HTML, and maintains all of the code/content separation you were asking for. Additionally, it requires no changes to the ConfirmButton extender which is always nice for me. :)

    Hope you like it!

    PS - "&#09;" is tab.


    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: ConfirmButtonExtender + Text Formatting

    05-02-2006, 4:50 AM
    • Participant
      1,526 point Participant
    • James_2JS
    • Member since 02-13-2006, 3:21 PM
    • Posts 335
    That's fantastic!! Thank you very much David... exactly what I've been looking for (but should really have known it I guess!!).

    Regards,

    James
  • Re: ConfirmButtonExtender + Text Formatting

    05-08-2006, 6:11 PM
    • Member
      20 point Member
    • thussain
    • Member since 05-08-2006, 10:05 PM
    • Posts 6

    Love your work and suggestion.

     

    However when I use this approach to put the text in the Confirm text section with my vb.net code it didn't work.

    Do you have any idea what this button does?&#10;&#10;Really??

    It apprears as it is no

    Do you have any idea what this button does?&#10;&#10;Really??

    I am not sure what I am doing wrong?

    Also when I havce more than one button on my Web Form  Each button require a confirm text how to have it it only for the specific button not for every button on the form.

     

    Thanks
    Tanweer

  • Re: ConfirmButtonExtender + Text Formatting

    05-08-2006, 7:16 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842
    • AspNetTeam
    Are you putting the "&#10;" entities in the .ASPX page (not the code-behind .ASPX.VB file)? If so, please post a small, simple demonstration of the problem. Thanks.

    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: ConfirmButtonExtender + Text Formatting

    05-08-2006, 7:28 PM
    • Member
      20 point Member
    • thussain
    • Member since 05-08-2006, 10:05 PM
    • Posts 6

    I am putting it in the Properties window of the confirmation text part where I put my message.

    Thanks
    Tanweer

  • Re: ConfirmButtonExtender + Text Formatting

    05-08-2006, 7:50 PM
    • Member
      20 point Member
    • thussain
    • Member since 05-08-2006, 10:05 PM
    • Posts 6

    Just to let you know in Html hat code is working ok.

    However when I use it in the Properties window of ConfirmButtonExtende ConfirmText and type the text with  &#10; it does not transalate to \n.

    I am using Vb.Net

     

     

    Also I haven't got any naswer how to turn off this Confirmatin box for other Buttons in the form.

     

    Thanks
    Tanweer

Page 1 of 2 (19 items) 1 2 Next >
Microsoft Communities