<SCRIPT language="javascript">$(function(){ // add multiple select / deselect functionality $("#selectall").click(function () { $('.case').attr('checked', this.checked); }); // if all checkbox are selected, check the selectall checkbox // and viceversa $(".case").click(function(){ if($(".case").length == $(".case:checked").length) { $("#selectall").attr("checked", "checked"); } else { $("#selectall").removeAttr("checked"); } });});</SCRIPT> |
Saturday, 21 December 2013
select all and deselect checbox in jquery
Wednesday, 18 December 2013
select dropdown in mvc using jquery
@{
ViewBag.Title = "Home Page";
}
<h2>@ViewBag.Message</h2>
<script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#cboFruits option[value='5']").attr('selected', 'selected');
});
</script>
<select name="cboFruits" id="cboFruits" onchange="PopulateDropDown('Banana')">
<option value="1">Apple</option>
<option value="2">Orange</option>
<option value="3">Mango</option>
<option value="4">Banana</option>
<option value="5">Pine</option>
</select>
output look like this:
ViewBag.Title = "Home Page";
}
<h2>@ViewBag.Message</h2>
<script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#cboFruits option[value='5']").attr('selected', 'selected');
});
</script>
<select name="cboFruits" id="cboFruits" onchange="PopulateDropDown('Banana')">
<option value="1">Apple</option>
<option value="2">Orange</option>
<option value="3">Mango</option>
<option value="4">Banana</option>
<option value="5">Pine</option>
</select>
output look like this:
Welcome to ASP.NET MVC!
check boxlist in mvc
My MVC Application
[ Log On ]
Welcome to ASP.NET MVC!
To learn more about ASP.NET MVC visit http://asp.net/mvc.
Thursday, 12 December 2013
mvc page security
i have two pages from login to details check using dictionary
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcUpdate.EF;
namespace MvcUpdate.Controllers
{
public class UserProfileController : Controller
{
//
// GET: /UserProfile/
test_dbEntities db = new test_dbEntities();
public ActionResult Index()
{
return View();
}
public ActionResult Getlogin(emp obj)
{
string name = obj.name;
string age = obj.age.ToString();
if (obj.name != null)
{
webSession.checkLogin(name, age.ToString());
if (webSession.checkLogin(name, age.ToString()) == null)
{
return View("index");
}
else
{
webSession.startSession(name, age);
TempData["key"] = name;
if (1 > 0)
{
return View("../Emp/index", TempData);
}
else
{
return View();
}
}
}
else
{
return View("index");
}
}
}
}
------------------------------------------------------------------------------------------------------------
@model MvcUpdate.EF.emp
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("Getlogin", "UserProfile", FormMethod.Post))
{
<div>
<table>
<tr>
<td>@Html.Label("User Name")</td>
<td>@Html.TextBoxFor(m => m.name)</td>
</tr>
<tr>
<td>@Html.Label("Password")</td>
<td>@Html.PasswordFor(m => m.age)</td>
</tr>
<tr>
<td>
<input id="submit1" type="submit" />
</td>
</tr>
</table>
</div>
}
</body>
</html>
----------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcUpdate.EF;
namespace MvcUpdate.Controllers
{
public class EmpController : Controller
{
//
// GET: /Emp/
test_dbEntities db = new test_dbEntities();
[OutputCache(Duration = 0)]
public JsonResult ShowEmployee()
{
if (webSession.validateSession(TempData["key"].ToString()) == null)
{
// return View("../UserProfile/index", TempData);
return Json(db.emps, JsonRequestBehavior.AllowGet);
}
else
{
var t = TempData["key"];
return Json(db.emps, JsonRequestBehavior.AllowGet);
}
}
[AcceptVerbs(HttpVerbs.Post)]
public JsonResult UpdateEmployee(int empId, string empName, int age)
{
emp Emp = db.emps.Single(em => em.id == empId);
Emp.name = empName;
Emp.age = age;
db.SaveChanges();
return Json("Record has Updated", JsonRequestBehavior.AllowGet);
}
public ActionResult Index()
{
int pageSize = 5;
int pageNo = 1;
int totalPage = db.emps.Count() / pageSize;
ViewData["tp"] = totalPage;
int skp = (pageNo - 1) * pageSize;
List<emp> Emp = db.emps.OrderBy(em => em.id)
.Skip(skp).Take(pageSize).ToList();
return View(Emp);
}
}
}
--------------------------------------------
------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MvcUpdate.EF;
namespace MvcUpdate
{
public class WebAuthentication
{
string _UserName, _Role;
public string Role
{
get { return _Role; }
}
public string UserName
{
get { return _UserName; }
}
public WebAuthentication(string userName, string role)
{
_UserName = userName;
_Role = role;
}
}
public class webSession
{
static Dictionary<string, string> _Users = new Dictionary<string, string>();
//public static void startSession(string sessionId, WebAuthentication user)
//{
// if (!_Users.ContainsKey(sessionId))
// {
// _Users.Add(sessionId, user);
// }
//}
public static WebAuthentication checkLogin(string name,string age)
{
test_dbEntities db = new test_dbEntities();
int kh =Convert.ToInt32(age);
if (age != null)
{ var p = (from k in db.emps
where k.name == name && k.age == kh
select k).ToList();
return new WebAuthentication(name, age.ToString());
}
else
{
return null;
}
}
public static string validateSession(string sessionId)
{
if (_Users.ContainsKey(sessionId))
{
return _Users[sessionId];
}
else
{
return null;
}
}
public static void endSession(string sessionId)
{
if (_Users.ContainsKey(sessionId))
{
_Users.Remove(sessionId);
}
}
internal static void startSession(string p,string age)
{
if (!_Users.ContainsKey(p))
{
_Users.Add(p,age);
}
}
}
}
--------------------------------------------------------------------------------------------------------------------
add class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcUpdate.EF;
namespace MvcUpdate.Controllers
{
public class UserProfileController : Controller
{
//
// GET: /UserProfile/
test_dbEntities db = new test_dbEntities();
public ActionResult Index()
{
return View();
}
public ActionResult Getlogin(emp obj)
{
string name = obj.name;
string age = obj.age.ToString();
if (obj.name != null)
{
webSession.checkLogin(name, age.ToString());
if (webSession.checkLogin(name, age.ToString()) == null)
{
return View("index");
}
else
{
webSession.startSession(name, age);
TempData["key"] = name;
if (1 > 0)
{
return View("../Emp/index", TempData);
}
else
{
return View();
}
}
}
else
{
return View("index");
}
}
}
}
------------------------------------------------------------------------------------------------------------
@model MvcUpdate.EF.emp
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("Getlogin", "UserProfile", FormMethod.Post))
{
<div>
<table>
<tr>
<td>@Html.Label("User Name")</td>
<td>@Html.TextBoxFor(m => m.name)</td>
</tr>
<tr>
<td>@Html.Label("Password")</td>
<td>@Html.PasswordFor(m => m.age)</td>
</tr>
<tr>
<td>
<input id="submit1" type="submit" />
</td>
</tr>
</table>
</div>
}
</body>
</html>
----------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcUpdate.EF;
namespace MvcUpdate.Controllers
{
public class EmpController : Controller
{
//
// GET: /Emp/
test_dbEntities db = new test_dbEntities();
[OutputCache(Duration = 0)]
public JsonResult ShowEmployee()
{
if (webSession.validateSession(TempData["key"].ToString()) == null)
{
// return View("../UserProfile/index", TempData);
return Json(db.emps, JsonRequestBehavior.AllowGet);
}
else
{
var t = TempData["key"];
return Json(db.emps, JsonRequestBehavior.AllowGet);
}
}
[AcceptVerbs(HttpVerbs.Post)]
public JsonResult UpdateEmployee(int empId, string empName, int age)
{
emp Emp = db.emps.Single(em => em.id == empId);
Emp.name = empName;
Emp.age = age;
db.SaveChanges();
return Json("Record has Updated", JsonRequestBehavior.AllowGet);
}
public ActionResult Index()
{
int pageSize = 5;
int pageNo = 1;
int totalPage = db.emps.Count() / pageSize;
ViewData["tp"] = totalPage;
int skp = (pageNo - 1) * pageSize;
List<emp> Emp = db.emps.OrderBy(em => em.id)
.Skip(skp).Take(pageSize).ToList();
return View(Emp);
}
}
}
--------------------------------------------
------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MvcUpdate.EF;
namespace MvcUpdate
{
public class WebAuthentication
{
string _UserName, _Role;
public string Role
{
get { return _Role; }
}
public string UserName
{
get { return _UserName; }
}
public WebAuthentication(string userName, string role)
{
_UserName = userName;
_Role = role;
}
}
public class webSession
{
static Dictionary<string, string> _Users = new Dictionary<string, string>();
//public static void startSession(string sessionId, WebAuthentication user)
//{
// if (!_Users.ContainsKey(sessionId))
// {
// _Users.Add(sessionId, user);
// }
//}
public static WebAuthentication checkLogin(string name,string age)
{
test_dbEntities db = new test_dbEntities();
int kh =Convert.ToInt32(age);
if (age != null)
{ var p = (from k in db.emps
where k.name == name && k.age == kh
select k).ToList();
return new WebAuthentication(name, age.ToString());
}
else
{
return null;
}
}
public static string validateSession(string sessionId)
{
if (_Users.ContainsKey(sessionId))
{
return _Users[sessionId];
}
else
{
return null;
}
}
public static void endSession(string sessionId)
{
if (_Users.ContainsKey(sessionId))
{
_Users.Remove(sessionId);
}
}
internal static void startSession(string p,string age)
{
if (!_Users.ContainsKey(p))
{
_Users.Add(p,age);
}
}
}
}
--------------------------------------------------------------------------------------------------------------------
add class
Subscribe to:
Comments (Atom)