Showing posts with label text. Show all posts
Showing posts with label text. Show all posts

Monday, March 26, 2012

ConfirmButtonExtender Change Button Text

I want to display the button text in Spanish, ie "Borrar" and "Cancelar" instead of "Ok" and "Cancel". How do I achieve this?.

Regards

Peeyush

hello

you can't change the alert buttns text ...

its the same as the browse button of file upload ,

the text depends on the language settings on the client browser .


The sample website at

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/OtherNeatStuff.aspx

says that strings displayed in the browser can be localized.

Can this help?


this can't be used for localizing the text of the alert buttons.

ConfirmButtonExtender + Text Formatting

Hi!

I often need to have some quite long confirmation messages for user actions, and would normally achieve this by formatting theConfirmText 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 areescaped and rendered as is!

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

Thanks,

James

Have you tried changing ConfirmButton.js's this._onClick method to unescape the string before displaying it? (Perhaps with JavaScript's regex functionality?)

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


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!
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
Okay, you win. :) I've added a note to try to address this in the next release. Thanks for the follow-up!

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!!


Hi David,

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

I have myButton andConfirmButtonExtenderembedded deep within aEditItemTemplate within aTemplateFieldin aGridViewinside aWizard!!
I hear you. I'm running another idea by folks to see if they like that any better...

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 " ", decimal value 10, which corresponds to the '\n' character. Changing the sample string to "Do you have any idea what this button does? 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 - " " is tab.


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

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? Really??

It apprears as it is no

Do you have any idea what this button does? 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


Are you putting the " " entities in the .ASPX page (not the code-behind .ASPX.VB file)? If so, please post a small, simple demonstration of the problem. Thanks.

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

Thanks
Tanweer


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 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

Saturday, March 24, 2012

ConfirmButton - Is it possible to control the button text in the pop-up?

Does anyone know if it is possible to control the button text in the pop-up? I would like to set the button text according to multi-language settings for the application.

Thanks,

Dave

Nop.. you can not control the text of the button in the popup. Since it depends on the client's browser language selection. If you need such customized popup try window.shomodalDialog or window.createPopup(); and put your own buttons.


Sounds like a perfect place to use the modalpopup extender to me!

Jason

conditional UpdatePanel doesnt work

I have the following simple code:

"UpdatePanel2" runat="server" UpdateMode="Conditional"> "Label3" runat="server" Text="Label"> "Button2" runat="server" Text="Button" onclick="Button2_Click">code behind:protected void Button2_Click(object sender, EventArgs e) { Label3.Text ="waiting..."; UpdatePanel2.Update(); Thread.Sleep(5000); Label3.Text ="done"; UpdatePanel2.Update(); }

But it doesn't update the panel until the end. i.e. you don't get to see the "waiting..." text (in fact, you don't see it at all) and then a 5 second pause, then"done". Why doesn't this work? I followed the video and couldn't find a mistake.

Thanks,
Yoni

Because the code in server.

When the system sleeping for 5 second,the runned client html data couldn't send toou client.so you cann't see "waiting...".

When the code in Button2_Click runned out,the html data just send to client,so you can see "done".

And you could change the code to client code as javascript code.

I hope you can understand the reason.Because I'm Chinese.I write English not well.


heyyonidebest,

the onclick event is a server side event , means the Button2_Click method will run at the server so everything happen inside the method you won't see it

the only way to see the situation you are describing is by using client side code


EnigmaOX:

heyyonidebest,

the onclick event is a server side event , means the Button2_Click method will run at the server so everything happen inside the method you won't see it

the only way to see the situation you are describing is by using client side code

I see. I can't convert this to JS because of other reasons. Is there a way to bypass this? Perhaps instead of trying to update the update pannel, I can call another procedure that does it somehow, via JS or else server side script. Is there such a way?

Thanks,
Yoni


Yep , you can use the trigger inside the update panel , plus a timer control

I'm not sure what are u trying to do but you can use the button event to change the text

and to start the timer and using the timer tick event you can fire another method after couple of seconds.


EnigmaOX:

Yep , you can use the trigger inside the update panel , plus a timer control

I'm not sure what are u trying to do but you can use the button event to change the text

and to start the timer and using the timer tick event you can fire another method after couple of seconds.

I see. I tried to create a hidden field object and write the following ValueChanged event:

protectedvoid HiddenField1_ValueChanged(object sender,EventArgs e)
{
UpdatePanel2.Update();
}

I then tried to call the event like this:

protectedvoid Button2_Click(object sender,EventArgs e)
{
Label3.Text ="waiting...";
HiddenField1.ValueChanged +=newEventHandler(this.HiddenField1_ValueChanged);
Thread.Sleep(5000);
Label3.Text ="done";
}

but still it did not work. I set the trigger to:

<asp:AsyncPostBackTriggerControlID="HiddenField1"EventName="ValueChanged"/>

yet still nothing. What am I missing? I don't need a timer because the update isn't based on time. i.e. I want to decide when to update the update panel.


heyyonidebest ,

well you still doing the same mistake , you will change the text of the label twice in the server so you won't see the waiting message

the idea is to change the text once in every event , for example Label.Text = "waiting..."; in the button2 click event and then start the timer control with 5 seconds tick

in the tick event change the text of the label again like Label.Text = "done...";

<asp:Timer ID="Timer1" runat="server" OnTick="timer1_Tick" Interval="5000" >
</asp:Timer>

privatevoid timer1_Tick(object sender, System.EventArgs e)
{
Label1.Text = "done...";
Timer1.Enabled = false; // to stop the timer

}

and use the tick event also to update panel

<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
 
Read more here : http://asp.net/AJAX/Documentation/Live/tutorials/TimerControlWithUpdatePanelsTutorial.aspx

Thanks,EnigmaOX.

But my code it more complicated that this small example. I have a few procedures that do stuff, and in the mean while I want to let the user know what the server is doing (plus so that I can debug). Thus, I can't see how a timer can help me. I can say one thing for sure - I need to let the user know what I doing - and during that time the server will be continuing it's work. Any other idea's how to refresh an update panel during while the server is working?

Yoni


sure , AjaxWink

you can do everything in ajax: webrequests , wcf services , registering postback scripts ect..


Well, how? the example I gave doen't work. can it be done w/o a timer?

Yoni


Take a look at doing it this way:http://encosia.com/2007/10/03/easy-incremental-status-updates-for-long-requests/

That's the sort of methodology you're going to need to consider. You can't provide incremental updates during a server call. Like a regular postback, a partial postback only outputs HTML once per round trip.


Better way you can use UpdateProgress Control

http://www.asp.net/ajax/documentation/live/overview/UpdateProgressOverview.aspx

conditional modal popup

Hi,

I'd like to use the modal popup in a conditional sense... i.e. only when someone has entered changes to the drops or text boxes on my page. The modal popup would then issue the standard "you have changed the data on this page... would you like to save your changes". If the pages has not changed, obviously, I would not like the modal popup to appear when navigating to the next/prev page.

Has anyone done this?

Any help is muchly appreciated.

Thanks

Hi,

You can have Javascript set off a dirty flag metioning that Data has changed and then raise the ModalPopup Using Script .

EX:

function RaisePopup(){

if( dataHasChanged()) {

//Raise Modal Popup

}

}

Read this link on how to show/Hide the modalPopup Using javascript

http://blogs.msdn.com/phaniraj/archive/2007/02/20/show-and-hide-modalpopupextender-from-javascript.aspx

Hope this helps


Thanks for the reply... i'll work on that

Hmm, how would you do it serverside? I have a situation where I'd like to use it with a login script, so the user enters there username and password click submit sends the data to the server which checks a database to see if that username and password exist if it does it returns with modalpopup.show() but it doesn't work.

Code is like this

loginButton_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles LoginButton.click'Bunch of user auth stuffif userExists = true then modalPopup.show()Else Status.Text ="Incorrect Login!"End IfEnd Sub
 
one problem I have is that modalpopup control requires a targetcontrolID so I set it to my submit button but than my submit button doesn't do a postback, so I
changed it and made the targetcontrolID the same as the PopupControlID with no luck now it does a post back but the modalpopup never pops up.
Any ideas how to make this work?