Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want to create a android mobile apps using html5 and jquery. here i have create a login.html page Which is placed in android Mobile apps.
how to get response form server without postback using jquery in same page. and store user id as cookies. after successfully login page redirect to success.html page after 5 sec.


login.html page <--- in android device
=====================
<html>
<head>
<title>Page Title</title>

CSS
#login
{
  display: block;

}
#msg
{
  display: none;

}


</head>

<body>

<form method="get" action="http://www.mysite.com/login.aspx">
<label> New Member Name</label>
<input id="tb_name" name="name" class="form-control" />

<label>
Password</label>
<input id="tb_pass" name="pass" type="password" class="form-control" />

<input id="btn_login" type="submit" value="Login..." />

</form>

Successfully login

</body>
</html>

login.aspx.cs page
=============

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using MySql.Data.MySqlClient;
using connect;

public partial class login : System.Web.UI.Page
{
MySqlConnection cn = new MySqlConnection();
connect_class cnn = new connect_class();
protected void Page_Load(object sender, EventArgs e)
{
cn = cnn.myconect();


string uid = Request.QueryString["name"];
string pass = Request.QueryString["pass"];
q_login(uid, pass);
}
public void q_login(string uid,string pass)
{
DataTable dt1 = new DataTable();
string SqlStr = "select * from login where user_id='" + uid + "' and pass='" + pass + "'";
MySqlDataAdapter dap1 = new MySqlDataAdapter(SqlStr, cn);
dap1.Fill(dt1);

if (dt1.Rows.Count > 0)
{
string temp = dt1.Rows[0][2].ToString(); // geting user type
string tmp = dt1.Rows[0][0].ToString();
string tuserid = dt1.Rows[0][3].ToString();
switch (temp)
{

case "USER":
Session.Add("uid", tmp);
Session.Add("username", tuserid);
string uID = Session["uid"].ToString();

Response.Redirect("login.html"); // page in android mobile apps.
break;
default:
lblerror.Text = "Invalid user or password,try again";

Response.Write("<script>alert('Invalid user or password,try again')</script>");

break;
}

}
}
Posted
Comments
F-ES Sitecore 26-May-15 7:08am    
Implement your authentication code in a web method and google ".net calling webmethod from jquery".

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