Custom "create usercontrol" for adding data to tables in database
Hi!
I'm trying to use the umbraco context menu create method to add data to some custom tables in my db.
I want to keep the default umbraco layout but decide where and how the data gets saved. I've created the content tree and also the user control with the correct textboxes etc. I also have a method in place to save the data.
I've used part of the tutorials on umbraco.tv to get this far but I can't use the simple.ascx control for adding data as I have several textboxes with custom validation rules.
Do I use the ITaskReturnUrl and should my save method inherit from a Umbraco interface?
Am I on the right path? If not what would be the right way to accomplish adding, deleting and editing custom data where you have total control over database table layout while mainting the umbraco look and utilizing umbraco's interfaces etc.
I'm not really sure what you mean by: "I've created the content tree", but I'm guessing you've made your own application/section?
Then you can create your own user control for the "new" operation, put it somewhere in the file structure and edit the /umbraco/config/create/ui.xml file.
The "path_to_your_folder" is relative to the /umbraco folder.
That's pretty much it. If you need to create custom delete actions etc. you'll need to implement your own class with the ITask interface, and add nodes below the <tasks> node.
Thank you for the reply. You're correct in assuming that I meant the application/section.
What I'm unsure about is the save method for my custom create-control. The example from umbraco.tv uses the simple.aspx. How do I let umbraco know whether the save-method succeeded or not? Is that via the ITask interface?
If you could maybe point me to an example of a custom "create"- usercontrol with eg. 2 input fields I would be very appreciative! :)
...the example "simple.ascx" recieves a single string value called "Alias" that corresponds to the input field available on simple.ascx. What if you have two input fields. Do I still use the ITask interface or do I just write my own save method and bypass Umbraco all together?
I would say that the ITask interface is there to make it easy for you if you can live with the restrictions the standard options have (like one field on the simple.ascx control etc.).
I would go for a custom web user control with the fields that you need, and then I would make my own save method on whatever class that makes sense. Then you only need to implement the ITask interface to make delete etc. work.
Well, I'm not sure how to get you an example. I mostly work with sub-classes of umbraco's CMSNode, so I would make a web user control that has the required fields, and then a button. The action (server-side) of the button would be:
Custom "create usercontrol" for adding data to tables in database
Hi!
I'm trying to use the umbraco context menu create method to add data to some custom tables in my db.
I want to keep the default umbraco layout but decide where and how the data gets saved. I've created the content tree and also the user control with the correct textboxes etc. I also have a method in place to save the data.
I've used part of the tutorials on umbraco.tv to get this far but I can't use the simple.ascx control for adding data as I have several textboxes with custom validation rules.
Do I use the ITaskReturnUrl and should my save method inherit from a Umbraco interface?
Am I on the right path? If not what would be the right way to accomplish adding, deleting and editing custom data where you have total control over database table layout while mainting the umbraco look and utilizing umbraco's interfaces etc.
I hope someone can give me a hand :)
Cheers,
Peter
I'm not really sure what you mean by: "I've created the content tree", but I'm guessing you've made your own application/section?
Then you can create your own user control for the "new" operation, put it somewhere in the file structure and edit the /umbraco/config/create/ui.xml file.
Put in these lines:
<nodeType alias="YOUR_APP_NAME">
<header>YOUR_HEADER</header>
<usercontrol>/PATH_TO_YOUR_FOLDER/createnode.ascx</usercontrol>
<tasks>
</tasks>
</nodeType>
The "path_to_your_folder" is relative to the /umbraco folder.
That's pretty much it. If you need to create custom delete actions etc. you'll need to implement your own class with the ITask interface, and add nodes below the <tasks> node.
regards,
Steen
Hi Steen,
Thank you for the reply. You're correct in assuming that I meant the application/section.
What I'm unsure about is the save method for my custom create-control. The example from umbraco.tv uses the simple.aspx. How do I let umbraco know whether the save-method succeeded or not? Is that via the ITask interface?
If you could maybe point me to an example of a custom "create"- usercontrol with eg. 2 input fields I would be very appreciative! :)
Regards,
Peter
...the example "simple.ascx" recieves a single string value called "Alias" that corresponds to the input field available on simple.ascx. What if you have two input fields. Do I still use the ITask interface or do I just write my own save method and bypass Umbraco all together?
I would say that the ITask interface is there to make it easy for you if you can live with the restrictions the standard options have (like one field on the simple.ascx control etc.).
I would go for a custom web user control with the fields that you need, and then I would make my own save method on whatever class that makes sense. Then you only need to implement the ITask interface to make delete etc. work.
Well, I'm not sure how to get you an example. I mostly work with sub-classes of umbraco's CMSNode, so I would make a web user control that has the required fields, and then a button. The action (server-side) of the button would be:
is working on a reply...