Welcome Guest Search | Active Topics | Sign In | Register

Binding Save button to event (HTML Editor) Options
Sunweb
Posted: Thursday, October 16, 2008 7:28:36 AM
Rank: Member
Groups: Member

Joined: 10/11/2008
Posts: 10
Can someone tell mee howw to bind the "save-button" in the HTML editor to an eventhandler.

I can see that the save-button has a command-name but I really can´t see how I should be able to connect the button with an handler that saves the data in the database. :-(

Regards /Sunweb
eo_support
Posted: Thursday, October 16, 2008 7:45:03 AM
Rank: Administration
Groups: Administration

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

Save is not only a command, but it's also an event. You would just handle the Save event like you handle a Button's Click event.

Thanks
Sunweb
Posted: Thursday, October 16, 2008 8:30:15 AM
Rank: Member
Groups: Member

Joined: 10/11/2008
Posts: 10
Mayby im just a bit slow :-)

The save-button is as written here:

<eo:ToolBarItem CommandName="Save" ImageUrl="00101003" ToolTip="Save">
</eo:ToolBarItem>

Im not able to add an onclick-event on this one - like a button-control - I guess I have to use the commandname - which is "Save" in default-mode?

eo_support
Posted: Thursday, October 16, 2008 8:36:06 AM
Rank: Administration
Groups: Administration

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

You looked much inside. :) The Save event is on the Editor control, not on the ToolBar control. The ToolBar control you see only controls what buttons appear. At runtime, the editor would take over all click events. If it sees a "Save" button, it fires Save event on the Editor.

A working example for this particular feature is available here:

http://www.essentialobjects.com/Demo/Default.aspx?path=Editor\_i2\_i2

You can check the source code of the sample to see how it works.

Hope this helps.

Thanks
Sunweb
Posted: Thursday, October 16, 2008 11:55:45 AM
Rank: Member
Groups: Member

Joined: 10/11/2008
Posts: 10
I have seen the example in the Demo - and I have looked through the source. :-)

Well - I can see the idea in attaching a Button control to the Editor - and then but a onclick method on the button which put the HTML into a database.

But I really can´t see how you will connect the save-button in the editor to handle the same :-(

eo_support
Posted: Thursday, October 16, 2008 12:30:14 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hum...you appear to have missed point. We said "you would just handle the Save event like you handle a Button's Click event", what we meant is:

EO Editor has a Save event. The way you use Save event on an Editor control is similar to the way you use Click event on a standard ASP.NET Button (not ToolBarButton!) control.

So if you know how to handle a standard ASP.NET Button control's Click event, you would follow the same steps to handle the Editor's Save event. The step to "bind" an eventhandler to a standard ASP.NET Button control's Click event is:

1. If you use Visual Studio, if you use C#, just double click the Button in design view; if you use VB, just go to the code window, select Button1 (or whatever name you give to the button) from the left listbox, and then "Click" from right side listbox;
2. If you work with HTML directly, you need to add OnClick attribute on your button this in your .aspx page;
Code: HTML/ASPX
<asp:Button OnClick="Button1_Click" ....>
....
</asp:Button>


And this in your .cs page:

Code: C#
protected void Button1_Click(object sender, EventArgs e)
{
  .....code to handle the button click event......
}


Similarly, when you use our Editor, you follow essentially the same step:
1. If you use Visual Studio, if you use C#, just double click the Editor in design view; if you use VB, just go to the code window, select Editor1 (or whatever name you give to the button) from the left listbox, and then "Save" from right side listbox;
2. If you work with HTML directly, add OnSave in your .aspx:

Code: HTML/ASPX
<eo:Editor OnSave="Editor1_Save" ...>
....
</eo:Editor>


Code: C#
protected void Editor1_Save(object sender, EventArgs e)
{
   .....code to handle the editor's ave event.....
}


The whole point is, how do you handle the click event of a standard ASP.NET button control? Follow the same step. Nobody is asking you to attach a standard ASP.NET Button to the Editor. The Editor is by itself a single control.

The database part is something separate. That has nothing to do with the editor or the button. Our sample shows you how to save the text to a file, which covers:

1. "Bind" the editor to an event handler;
2. Get the editor's text into a string;
3. Save the string into a file;

You will need to change step 3 to saving the string into your database (do not ask us how to do this....this has nothing to do with us!).

Hope this helps. If this still does not make any sense to you, then you may want to ask somebody around you to help you. The should be able to show you how it works in a few seconds.

Thanks
Sunweb
Posted: Thursday, October 16, 2008 12:50:55 PM
Rank: Member
Groups: Member

Joined: 10/11/2008
Posts: 10
Oh my god - yes offcourse!

I missed this on my way to wisdom:

Code: HTML/ASPX
<eo:Editor OnSave="Editor1_Save" ...>
....
</eo:Editor>


The build-in events in the control - I didnt notice them.

Thanks a lot for the help and 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.