You must Sign In to post a response.
  • Category: ASP.NET

    Updating database on button click from email body

    hi Developers ,

    I am sending an email from my Application (C#.net). Body of email have 2 buttons approve and Reject ..I want to know whether i can update database on clicking approve or reject button without opening any link to my application.

    i get confused so suggest me to i am done this task
  • #769116
    You can try this code in your source with simple ajax

    <!DOCTYPE html>

    <html> <head>

    <title></title>

    <meta charset="utf-8" />

    <script src="Scripts/jquery-1.10.2.js"></script>

    <script type="text/javascript"> // Ajax call using jquery to your website's page
    function callAjax(actiontype)

    { var request = $.ajax({ url: "http://yoururl/webform1.aspx", method: "GET", data:

    { paramvalue: actiontype }, dataType: "html" }); }

    </script>

    </head>

    <body>

    <input type="button" onclick="callAjax('Accept');" value="Accept" />

    <input type="button" onclick="callAjax('Reject');" value="Reject" />

    </body>

    </html>

    Code snippet for catch the parameter based on button click and do update on the DB.

    public partial class WebForm1 : System.Web.UI.Page

    {

    protected void Page_Load(object sender, EventArgs e)

    { var action = Request.QueryString["paramvalue"];

    if (!string.IsNullOrEmpty(action)) { // implement the rest of the stuff

    if (action.ToLower() == "accept")

    { // update DB } else if (action == "reject")

    { // Update DB } } }


Sign In to post your comments