|
Rank: Advanced Member Groups: Member
Joined: 10/20/2008 Posts: 75
|
How can i configure the Dialog to request the confirm to the user who want delete?
this is what I do: DELbutton.Attributes.Add("onclick", "if(!confirm('Cancellare il contatto " + e.Row.DataItem("email") + "?')) return false;") and is ok.
Now I want to do this using EO.dialog object... can you help me? How can I get the return value from Dialog? How can I set programmatically the content template? Thanks. Andrea
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, The difference is only how you access the button. When you have a button in the form, you can access it directly by the name, when you have a button inside a dialog's ContentTemplate, you would do:
Code: C#
Button delButton =
(Button)Dialog1.ContentContainer.FindControl("DELButton");
delButton.Attributes.Add(....);
There is no such thing as "return value from Dialog". The dialog shows you a modal UI. You can place then place other control inside that UI and handle their events. You can not programmatically set the dialog's ContentTemplate. You can however programmatically modifies child controls inside its ContentTemplate as demonstrated above. Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 10/20/2008 Posts: 75
|
Hi, delButton is in my 'standard' Gridview and I 've no problem to access to it.
When I click on my 'delButton': I should: 1. Open a modal dialog with some dynamic information 2. If the user click to 'ok' on modal Dialog, delete the record. 3. If the user click to 'no' on modal Dialog, do nothing.
I should create the some user experience that now I do with javascript:confirm() but using EO.Dialog control to realize the best grafichs layout. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 10/20/2008 Posts: 75
|
For the "return value from Dialog", I took the cue in doumentation, in "Demo - Accept and Cancel Button" there's said
"Use AcceptButton and CancelButton to specify the ID of the "accept button" and "cancel button". The dialog closes when these buttons are clicked. In this case the button's CommandName value will be used as the dialog's result value. "
But there's no dimostrate how can I should use the "result value" !
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, Andrea. That "return value" can be accessed via JavaScript: http://www.essentialobjects.com/ViewDoc.aspx?t=JSDoc.Public.Dialog.getResult.htmlHowever, that's not what you want. In your case, you would simply: 1. Clear your dialog's AcceptButton property; 2. Handle your AcceptButton's Click event directly like you do with any other button;
Code: HTML/ASPX
<asp:Button id="OKButton" OnClick="OKButton_Click" ... />
That way when the button is clicked, it posts back the page and call your server side OKButton_Click handler. You can delete the records there. You may also need to store a "record ID" inside a hidden field after your delButton is clicked. That way when OKButton_Click is called you know which record to delete. Hope this helps. Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 10/20/2008 Posts: 75
|
yes, you help me! The last thing is: How can I send the information of RECORD ID to Dialog? My steps are:
1. DELbutton on my Gridview open Dialog control: DELbutton.Attributes.Add("onclick", "eo_GetObject('Dialog1').show(true);") 2. OKbutton on DialogControl posts back te page and call server side OKbutton_Click 3. OKbutton_Click delete the record with the RECORD ID that I have send with an hidden field
I need to know how can I
|
|
Rank: Advanced Member Groups: Member
Joined: 10/20/2008 Posts: 75
|
yes, you help me! The last thing is: How can I send the information of RECORD ID to Dialog? My steps are:
1. any DELbutton on my ROWS of my Gridview open Dialog control with DELbutton.Attributes.Add("onclick", "eo_GetObject('Dialog1').show(true);")
2. OKbutton on DialogControl posts back te page and call server side OKbutton_Click 3. OKbutton_Click delete the record with the RECORD ID that I have send with an hidden field
I need to know how can I send to Dialog the value of RECORD ID! thanks, Andrea
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi Andrea, You do not send the record ID to the dialog. You send the record ID to your server side OKButton_Click. The dialog shows you the UI but has nothing to do with how you pass the record ID from your client side code to your server side code. One way to do this is to store the value into a hidden field. You would do: 1. Put a hidden field in your form. For example:
Code: HTML/ASPX
<input type="hidden" id="record_id" name="record_id" />
2. Use the following JavaScript to set the value on the client side:
Code: JavaScript
document.getElementById("record_id").value = your_record_id;
3. Use the following C# code to get the value on the server side:
Code: C#
string record_id = Request.Form["record_id"];
Obviously record_id is just an example here. You can pass anything that can be used to identify which row's button was clicked --- for example, you may consider passing row number instead of record_id here. Regardless whether you want to pass record_id or row number, or whatever else, you will need to get that value and pass it to your DELButton's onclick script first (so that your onclick script can call step 2 to store the value). If you use a TemplateField, you can easily do that with data binding expression. The details about data binding is out of the scope of our support, so you may wish to seek help from other resource. Hope this helps! Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 10/20/2008 Posts: 75
|
Hello, I've try with this code:
<asp:TemplateField> <ItemTemplate> <asp:ImageButton ID="del" runat="server" Width="24px" ImageUrl="vbografica/row_del.png" OnClientClick=<%# string.format("document.getElementById('IdToDel').value='{0}'; eo_GetObject('Dialog1').show(true);" , Eval("ID") ) %> /> </ItemTemplate> <ControlStyle Width="30px" BorderStyle="None" /> </asp:TemplateField>
But when I click the dialog opens and close.
|
|
Rank: Advanced Member Groups: Member
Joined: 10/20/2008 Posts: 75
|
I've add
return false;
after eo_GetObject('Dialog1').show(true);
and the dialog1 stay open!
thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 10/20/2008 Posts: 75
|
Hello,... I've the problem that I've put a Label in the Dialog1. I update the label with the value of <input type="hidden" id="record_id" name="record_id" /> that I update with onClientClient. The problem is that if I update the value in
Private Sub Dialog1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Dialog1.Load Dim id As String = Request.Form("IdToDel") If id <> Nothing Then Lb_conferma.Text = "Are you sure to delete:<br>" & id.ToString End If End Sub I don't have the value updated!
Can You suggest to me how can I do it? I've just try with _init and _prerender Thanks thanks! Andrea
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, You might be confused about client side code and server side code. No server side code will be invoked when the dialog is displayed. All server side code, including Load, Init or PreRender, are called when the page is initially rendered. Once rendered, displaying the dialog is simply turning the already rendered DHTML from invisible to visible on the client side. If you wish to update dialog content when you display it, you can either do it by JavaScript or need to post back to the server first. If you do postback, it means to let the Grid column button to raises Grid's server event. Inside those event handlers you can then update whatever you wish to update, then use the following code to display the dialog:
Code: C#
Dialog1.InitialState = EO.Web.DialogState.Visible;
This is the server side equivalent of "eo_GetObject('Dialog1').show(true);". Hope this helps. Thanks
|
|