Welcome Guest Search | Active Topics | Sign In | Register

Dialog and CallBacks Options
Bentechsoft
Posted: Sunday, March 29, 2009 12:22:07 AM
Rank: Member
Groups: Member

Joined: 3/5/2009
Posts: 12
Hi,

What is the best strategy to use Dialog, combine with CallbackPannels . Here's what I want to do.

1-) I use a Dialog to enter data which is validated and saved to a database when OK button is clicked. The validation is done on the server side.

2-) The content of the dialog is filled with a "user control"... Mainly a HTML table with some ASP controls in it. In case of errors, I display error messages in a DIV. The validation code is activate through a method name SaveData which is called from the codebehind of the OK button of dialog.

3-) The dialog is close and opened from the server side (the code behind of the OK button.)

I need my dialog to display the error messages without flashing.

Question: Where should I place the CallBackPanel? Whick control should be used as triggers. I thought of usering the OK button but it is not visible from my user control.

Maybe you have some example I could look at?

Thanks
eo_support
Posted: Sunday, March 29, 2009 9:07:34 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Have you tried to move the CallbackPanel inside the dialog? It will be the dialog contains CallbackPanel, CallbackPanel then contains your user control and the button. You can then set the OK button as a trigger for the CallbackPanel.

Thanks!
Bentechsoft
Posted: Sunday, March 29, 2009 2:10:14 PM
Rank: Member
Groups: Member

Joined: 3/5/2009
Posts: 12
Yes... It works. The only thing is I have to put the user control and the buttons in the ContentTemplate section of the dialog.

I would like to use the FooterTemplate section to put my user control. If I put the control panel in the ContentTemplate section and the buttons in the FooterTemplate section, I get a run time error

Is this normal

Thanks
Bentechsoft
Posted: Sunday, March 29, 2009 3:21:48 PM
Rank: Member
Groups: Member

Joined: 3/5/2009
Posts: 12
Ok,

I've done some more testing. Using a callbackpanel inside the dialog works but there are some problems.

1-) If The main page uses a CallBackPanel (I get the same behavior with a AJAX ASP.NET ScriptManager and UpdatePanel) and the Dialog also use a CallBackPanel. The dialog does not close when using the following line of code

Me.DlgCredential.InitialState = EO.Web.DialogState.Hidden

2-) If I don't use a CallBackPanel inside my dialog. The dialog will display my error messages properly but a flicker will occur (like a page reload) but the it will close properly.

It this normal?

Thanks
eo_support
Posted: Sunday, March 29, 2009 4:02:06 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Both are normal. The basic rule at here is if you let the dialog to be updated on the server side (by placing it inside CallbackPanel or UpdatePanel), it will reloaded and you will see it flicker.

The solution is quite simple. Just remove the CallbackPanel from the main page (so that the dialog is NOT inside the CallbackPanel) and the close the dialog with JavaScript. Use the following steps to close the dialog with JavaScript:

1. Place the CallbackPanel inside the dialog (So that you will not be able to close the dialog with "Me.DlgCredential.InitialState = EO.Web.DialogState.Hidden");

2. Place a Label inside the CallbackPanel;

3. Assign the following value to the Label's Text when you want to close the dialog:

"<script type='text/javascript'>eo_GetObject('DlgCredential').close();</script>"

This renders a piece of JavaScript code to the client side and calls our client side JavaScript API to close the dialog.

You may want to go over this topic if you are not faimilar with our client side JavaScript interface:

http://doc.essentialobjects.com/library/1/clientapi_howto.aspx

As for ContentTemplate and FooterTemplate, the rule is in order for a control to be set as a trigger, the control must be in the same NamingContainer as the CallbackPanel. ContentTemplate and FooterTemplate defines two different naming containers. The workaround is once again using JavaScript:

http://doc.essentialobjects.com/library/1/jsdoc.public.global.eo_callback.aspx

You can use this function to trigger a Callback from anywhere without explicitly using a trigger control. Note without a trigger control, you will not have the server side trigger control event (for example, your Button Click event) either. So you will need to have additional code to check whether it is a Callback on the server side and acts accordingly.

On the other hand, you do not have to use FooterTemplate at all. Anything you can put in FooterTemplate can be placed in ContentTemplate and some simple HTML tweaking can make them look the same. So I do not believe you must put the OK button inside FooterTemplate.

Hope this helps.

Thanks!
Bentechsoft
Posted: Wednesday, April 1, 2009 12:03:43 AM
Rank: Member
Groups: Member

Joined: 3/5/2009
Posts: 12
Thanks for your reply, it rely help! I was able to do what I wanted.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.