Welcome Guest Search | Active Topics | Sign In | Register

EO Dialog Options
Michael Smit
Posted: Friday, February 15, 2008 12:02:55 PM
Rank: Member
Groups: Member

Joined: 6/6/2007
Posts: 19
Hi,

I have an webpage that monitors a com port for value from a weighbridge scale. Sometimes the user needs to manually enter values and override what the scale is sending in.
In the event the user manually enters numbers, I would like the EO dialog to popup to prompt for a username/password as a clerk is not allowed to manually enter the weight and an admin is needed to provide credentials.

So the typical path would be...

User manually enters weight.
Submit button is clicked. Javascript checks to see where the weight came from, it from the component monitoring the comport, then allow the submit and post back to the server.
If the value was a manual entry (I have logic for checking this already), the show the dialog. If the user clicks OK, true is returns to the JS function, and the submit continues (credentials checked at the server on postback). If cancel is clicked in the dialog, the submit process halts.

Does this make sense, and is it possible?
eo_support
Posted: Friday, February 15, 2008 12:16:33 PM
Rank: Administration
Groups: Administration

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

It's possible. Once the dialog is displayed, whether you are using a dialog or not should not have any impact on the result of your code. I imagine that you would have another "OK" or "Submit" button in the dialog to submit the credential. While the button is the dialog, it is also in the page. So perform whatever logics that you would perform as if the button is directly in the page. If that logic fails, the dialog would still be there; if it succeeded, the page posts back. You do not need to worry about closing the dialog. When you click the cancel button the dialog closes and nothing happens.

Let us know if you still need any more help!

Thanks
Michael Smit
Posted: Friday, February 15, 2008 12:22:19 PM
Rank: Member
Groups: Member

Joined: 6/6/2007
Posts: 19
Ye.. I do need more help. I cannot hook the ShowButton property of the dialog as I do not know if the dialog must be shown until the user clicks the page "Submit" button.

I have a JS function that is called when the user clicks Submit. In this function I check to see if the value came from the weighbridge or was a manual entry. If weighbridge, I just return true and postback continues.
If it is a manual entry, I need to be able to display the dialog from the JS function, wait for the result of the dialog (submit/cancel) then continue to postback or not depending on the result of the dialog.

So... I need to be able to call a show method or something in the EO dialog. This I don't know how to do. I then need to be able to test the result of showing the dialog to determine if the JS function must return true or false. This I also don't know how to do.
eo_support
Posted: Friday, February 15, 2008 12:31:56 PM
Rank: Administration
Groups: Administration

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

In your case you need to use this function instead of ShowButton to display the dialog:

http://www.essentialobjects.com/ViewDoc.aspx?t=JSDoc.Public.Dialog.show.html

Just do something like this:

Code: JavaScript
if (manual_entry)
    Dialog1.show(true);


Thanks
Michael Smit
Posted: Friday, February 15, 2008 12:50:58 PM
Rank: Member
Groups: Member

Joined: 6/6/2007
Posts: 19
I must be really stupid here guys...

I cannot use the Dialog ID as it has a ClientID when sent to the browser, so doing the following...

This is the JS function

function Capture(weightTextboxID, adminDialog)
{
try
{
var dialog = document.getElementById(adminDialog);
dialog.show(true);

// Need to test the result of dialog.show... How?

return false;
}
catch (ex)
{
alert(ex.description);
return false;
}
}

Then the C# code that creates the OnClick event hander for the submit button

SubmitButton.Attributes.Add("onclick", "return Capture('" + WeightTextBox.ClientID + "', '" + adminLoginDialog.ClientID + "');");

adminLoginDialog is the server ID of the dialog I am trying to get displayed.

When I click submit, the function is called, adminDialog is not null so should work, but I get "object doesn't support this property or method" displayed, so think it does not know how to do the Show thing.

Please note my comment in the JS code where I need to test the result of show. Still don't know how to do this. Does it return true/false?
eo_support
Posted: Friday, February 15, 2008 12:54:33 PM
Rank: Administration
Groups: Administration

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

Instead of using document.getElementById, you would use eo_GetObject. Our client side object and the corresponding DHTML objects are different. The rest of your code looks good.

You can find more information on how to use our client side API at here:

http://www.essentialobjects.com/ViewDoc.aspx?t=clientapi_howto.html

Thanks

Michael Smit
Posted: Friday, February 15, 2008 1:10:18 PM
Rank: Member
Groups: Member

Joined: 6/6/2007
Posts: 19
GREAT!!! That works... Thanks!

Now the very tricky part :)

How to show the dialog in JS, and test the result? I understand I can hook a "Accept" client side event, but that confuses me. My Capture function must always return false then to prevent the postback, and in the "Accept" event I need to re-initiate the postback. Seems messy, and I don't know how anyway.

Is there no way to simply show the dialog and wait for it to close to test the result?
IE:

var dialog = eo_GetObject("adminLoginDialog");
var result = dialog.show(true);

Then test result to see how to handle this?

eo_support
Posted: Friday, February 15, 2008 1:20:49 PM
Rank: Administration
Groups: Administration

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

You never do. When the dialog is displayed, regardless modal or modeless, dialog.show returns immediately. So there never is a result from the dialog.

As for the Accept button, it's just another button (do not use AcceptButton property). The button triggers a postback like any other standard ASP.NET button and that's it. The fact that it sits in the dialog does not mean programmatically it has anything to do with the dialog. By the time your user click accept button, your previous submit attempt has already been abandoned, so the only questions is whether you trigger a new postback now or not, there isn't a question of how to re-initiate the previous post back.

Hope this helps.

Thanks
Michael Smit
Posted: Friday, February 15, 2008 1:23:44 PM
Rank: Member
Groups: Member

Joined: 6/6/2007
Posts: 19
Ye... ALL comments did help. I have it working well and did as suggested..

If the user needs to enter credentials, the Capture function returns false and halts the postback. The Submit button in the dialog then handles the postback and the common Save method is called in the code behind, and it is working really well.

Thank-you so much for all your help, and in particular, your super speedy responses. What I thought would be a nightmare to implement is working very elegantly and is sure to wow the users.

Good going EO team. You'll have my support forever.
eo_support
Posted: Friday, February 15, 2008 1:29:36 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Excellent! Glad to hear it's working for you. Certainly appreciate your support!


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.