|
Rank: Newbie Groups: Member
Joined: 2/5/2009 Posts: 5
|
Hello,
I would like to know, how can i handle with the Dialog Close button click event? I need to call a Server side function when the client click on the Dialog Close button.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
You would just put a regular button inside the dialog and use it the same way as with any other button. The button would have nothing to do with the dialog except for that it is placed inside the dialog. When user clicks the button, the page posts back and trigger your server side event. The dialog automatically closes when the page posts back.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 2/5/2009 Posts: 5
|
Hello again,
Ok, but I want to do it using the pre-build Dialog Close Button placed at the top-right on the Dialog. Is it possible?
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, The close button does not trigger any server event directly. However it does trigger client side JavaScript event: http://doc.essentialobjects.com/library/1/eo.web.dialog.clientsideoncancel.aspxYou can write a JavaScript handler for this event and then trigger a post back from your JavaScript code (for example, calling __doPostBack). You will need to code accordingly so that your server side code can distinguish the post back is from your JavaScript code. Thanks
|
|
Rank: Newbie Groups: Member
Joined: 2/5/2009 Posts: 5
|
Hi,
Ok, I got it! But, now the problem is I'm writing the javaScript _doPostBack on the dialog.ClientSideOnCancel and it doesnt trigger anything. Do I have to set as True any PostBack property of the dialog?
My code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim PostBackStr As String PostBackStr = Page.ClientScript.GetPostBackEventReference(Me, "ClosePostBack")
Dialog2.ClientSideOnCancel = PostBackStr
If Page.IsPostBack Then Dim eventArg As String = Request("__EVENTARGUMENT") If eventArg = "ClosePostBack" Then MsgBox("It works!") End If End If
End Sub
Thanks,
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
ClientSideOnCancel takes a JavaScript function name, not Javascript code. So you will need to have a client side JavaScript function first.
Thanks
|
|