Show dialog or popup after database insertion using jQuery Mobile -


i'm using webmatrix jquery mobile develop simple mobile web page involves database operations. 1 of requirements show alert-like dialog inform users how operation goes. i've done researches, couldn't find working solution when comes database operations. followings best can do, there seems problem though.

  1. the data insertion successful, goes redirect in catch block, ignoring 1 in try block.

  2. this not practice. can give me direction implement more efficiently?

thanks in advance.

default.cshtml

@{     layout = "~/_layout.cshtml";     page.name = "test adding records";     if (ispost)     {         string strfirst, strsecond;         strfirst = request.form["first"];         strsecond = request.form["second"];          var database = database.open("testdb");         string strsql = "insert testtable " +             "(firstcol, secondcol) " +             "values(@0, @1);";         try{             database.execute(strsql, strfirst, strsecond);             response.redirect("~/msg.cshtml?msg=successfully");         }         catch(exception ex){             response.redirect("~/msg.cshtml?msg=failed");         }     } }  <div data-role="page">     <div data-role="header">         <h1>add record</h1>     </div>     <div data-role="content">         <form method="post" action="">             <div data-role="fieldcontain">                 <label for="first">first column:</label>                 <input type="text" name="first" id="first" value="@request.form["first"]" />             </div>             <div data-role="fieldcontain">                 <label for="second">second column:</label>                 <input type="text" name="second" id="second" value="@request.form["second"]" />             </div>             <div data-role="fieldcontain">                 <input type="submit" value="add record" />             </div>         </form>     </div> </div> 

msg.cshtml

@{     string message = request.querystring["msg"];     string previousurl = request.urlreferrer.tostring(); }  <!doctype html>  <html lang="en">     <head>         <meta charset="utf-8" />         <title></title>         <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />         <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>         <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>        </head>     <body>         <script type="text/javascript">             alert('@message');             window.location.replace('@previousurl');         </script>     </body> </html> 

try small modification

    try{         database.execute(strsql, strfirst, strsecond);     }     catch(exception ex){         response.redirect("~/msg.cshtml?msg=failed");     }     response.redirect("~/msg.cshtml?msg=successfully"); 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -