Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written the code for success message after submitting in database.But the code behind is not working and jquery is working.
Here is my code.
JavaScript
$(document).ready(function () {
$("#ContentPlaceHolder1_btnsubmit").live("click", function () {
$("#dialog").dialog({
autoOpen: false,
hide: "puff",
title: "Message",
buttons: {
Close: function () {
$(this).dialog('close');
var url = '../View/Home.aspx';
$(location).attr('href', url);
}
},
modal: true
});
return false;
});
});

protected void btnsubmit_Click(object sender, EventArgs e)
   {         
            RegisterObject robj = new RegisterObject();
            robj.fname = txtfname.Text;
            robj.lname = txtlname.Text;
            robj.dob = txtdob.Text;
            robj.email = txtemail.Text;
            robj.role = ddlrole.Text;
            robj.user_id = txtuserid.Text;
            

            string strpassword = Encryptdata(txtpwd.Text);
            robj.password = strpassword;
            RegisterLogic RL = new RegisterLogic(robj);
   }
Posted
Comments
Andy Lanng 23-Jun-15 4:13am    
please post the markup for your button.
Doing both is tricky. You must do the javascript before the submit. There are ways to do this but seeing how you have your button will help in our answer.

Click the "Improve Question" button above this comment to add to the question.

Thanks ^_^

1 solution

Remove the
JavaScript
"return false"
from the bottom of the client side click event. That would call the server side click event.

To make it work correctly call an async logic or func to handle the registration process. Instead of calling client side event as well as server side event.

Call registration logic using jquery ajax
Then handle the onsuccess/onerror callback methods to display message in a dialog.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900