I am new to Umbraco. I have a pop up (using jquery dialog) to enter name and email id from user. The values are store in name.val() and email.val().How to save name and email id entered from the user to the database ?
There are many different ways you could achieve this. One would be to create a /base extension, similar to a web service, and pass in the user's name/email through the URL (like /base/Users/SaveUserInfo/Tom/[email protected]) - or you could POST the data to avoid having it in the URL. In your base extension you could handle saving it to the database.
Here is a blog post explaining how to create the base (RestExtension) in 4.7, it's very easy: http://www.nibble.be/?p=95
//Here i need to send the name.val() and email.val() to be stored in the table } }, Cancel: function() { $( this ).dialog( "close" ); } }, }); </script>
Din't know the ways of passing the values in the dialog to the backend.
What you'll want to do there is make an AJAX call to the RestExtension you create. Look into jQuery.ajax to do this. The URL would be something like "/base/Users/SaveUserInfo/" + name.val() + "/" + email.val()
You'll need to create a RestExtension with two parameters (name/email) to handle the request and write the code to add to the database.
Saving user input
Hi,
I am new to Umbraco. I have a pop up (using jquery dialog) to enter name and email id from user. The values are store in name.val() and email.val().How to save name and email id entered from the user to the database ?
Regards,
Ambika
Hi,
There are many different ways you could achieve this. One would be to create a /base extension, similar to a web service, and pass in the user's name/email through the URL (like /base/Users/SaveUserInfo/Tom/[email protected]) - or you could POST the data to avoid having it in the URL. In your base extension you could handle saving it to the database.
Here is a blog post explaining how to create the base (RestExtension) in 4.7, it's very easy: http://www.nibble.be/?p=95
-Tom
Many Thanks Tom. I have the data in the script tag. Will the RestExtension still hold good?
<script>
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
show: "blind",
modal:true,
hide: "slide",
buttons: {
"Create an account": function() {
var bValid = true;
allFields.removeClass( "ui-state-error" );
bValid = bValid && checkLength( name, "username", 3, 16 );
bValid = bValid && checkLength( email, "email", 6, 80 );
if ( bValid ) {
//Here i need to send the name.val() and email.val() to be stored in the table
}
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
});
</script>
Din't know the ways of passing the values in the dialog to the backend.
- Amby
Hi Amby,
What you'll want to do there is make an AJAX call to the RestExtension you create. Look into jQuery.ajax to do this. The URL would be something like "/base/Users/SaveUserInfo/" + name.val() + "/" + email.val()
You'll need to create a RestExtension with two parameters (name/email) to handle the request and write the code to add to the database.
Hope this helps,
Tom
It worked.. Thanks Tom for the advice and the link.
-Amby
Alternative way is to have a hidden field and use ajax submit() to post the page.
is working on a reply...