Welcome Guest Search | Active Topics | Sign In | Register

Pass arguments to the ClientSideOnAccept function Options
Duane
Posted: Friday, February 13, 2009 4:17:00 PM
Rank: Advanced Member
Groups: Member

Joined: 9/4/2007
Posts: 114
Is it possible to pass arguments to the ClientSideOnAccept javascript function defined for a dialog?
If possible, ideally it would resolve, or somehow accept, the AcceptButton (Button.UniqueID) defined for that dialog.

The idea is to have generic function that would handle the click/enter event for all common dialogs accept buttons and execute (eval) the WebForm_DoPOpstBackWithOptions() function and be able to resolve the name of the button for that dialog.

If it is not possible to pass the button name (resolved to <%= Button.UniqueID %>), how would I find the Accept Button UniqueID using javascript for the specific dialog in a generic function?

Here's the jist of what I would like to do:

Code: JavaScript
function handleClick(button) {
  eval("WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('" + button + "', '', true, '', '', false, true))");
}


Code: HTML/ASPX
<eo:Dialog  ID="dialog" 
  ShowButton="showButton" 
  runat="server" 
  ...
  AcceptButton="myAcceptButton"
  ClientSideOnAccept="handleClick('<%= myAcceptButton.UniqueID %>')"> 
...
<asp:Button ID="myAcceptButton" runat="server" Text="Accept Button" OnClick="Create_Click" />

eo_support
Posted: Friday, February 13, 2009 4:43:56 PM
Rank: Administration
Groups: Administration

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

ClientSideOnAccept takes a function name. So your code that passes a function is incorrect. Your code never calls the handler directly. Instead it is always called by the dialog, and the dialog always passes two arguments to your function:

http://doc.essentialobjects.com/library/1/jsdoc.public.handlers.dialog_event_handler.aspx

The second argument is the DOM event object. So you can get your event source from there.

A much easier way might be store whatever argument you want to pass in a global variable. You can also store it as a member on the dialog object. You can then check that variable in your handler. In any case, you never directly "pass in" anything because you do not directly call your handler.

Thanks!


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.