if (e.Row.RowType == DataControlRowType.DataRow && gridCategory.EditIndex ==e.Row.RowIndex)
{
string MenuName = ((HiddenField)e.Row.FindControl("hiddenMenuName")).Value;
DropDownList ddlMenu = (DropDownList)e.Row.FindControl("ddlMenu");
bindddMenu(ddlMenu, MenuName);
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
DropDownList ddlMenu = (DropDownList)e.Row.FindControl("ddlMenu");
bindddMenu(ddlMenu, "");
}
else if (e.Row.RowType == DataControlRowType.EmptyDataRow)
{
DropDownList ddlMenu = (DropDownList)e.Row.Controls[0].Controls[0].FindControl("ddlMenu");
bindddMenu(ddlMenu, "");
}
OR
protected void gridCategory_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.EmptyDataRow)
{
DropDownList ddlMenu = (DropDownList)e.Row.FindControl("ddlMenu");
bindddMenu(ddlMenu, "");
}
}
Sunday, August 11, 2013
Bind DropDownList in Edit Footer And Empty templates
Thursday, August 8, 2013
CSS For Grid
<style type="text/css">
.grid
{
border:1px solid #111111;
margin: 5px 0 10px 0;
width:95%;
font-size:1.2em;
}
.grid a:link
{
color:#114477;
}
.grid tr th
{
background-color:#336699;
color:#FFFFFF;
height:25px;
font-weight:bold;
}
.grid tr, .grid th, .grid td
{
padding:5px;
}
.grid tr
{
background-color:#FFFFFF;
color:#222222;
}
.grid tr.alt
{
background-color:#EDEDED;
color:#222222;
}
.grid .pgr td
{
background-color:#bdbdbd;
font-weight: bold;
color:#555555;
padding:1px;
}
.grid .pgr td a
{
padding:1px;
}
.grid .pgr td span
{
padding:1px;
}
</style>
Sunday, July 28, 2013
Forms Authentication
void Application_AuthenticateRequest(object sender, EventArgs e)
{
if (HttpContext.Current.User != null)
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
if (HttpContext.Current.User.Identity is FormsIdentity)
{
FormsIdentity formsIdentity = (FormsIdentity)HttpContext.Current.User.Identity;
string[] userRoles = formsIdentity.Ticket.UserData.Split(',');
HttpContext.Current.User = new GenericPrincipal(formsIdentity, userRoles);
}
}
}
}
protected void Login_Click(object sender, EventArgs e)
{
FormsAuthenticationTicket formsAuthenticationTicket = new FormsAuthenticationTicket(1, "abcd", DateTime.Now, DateTime.Now.AddMinutes(30), false, "Admin");
string encryptedFAT = FormsAuthentication.Encrypt(formsAuthenticationTicket);
HttpCookie httpcookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedFAT);
HttpContext.Current.Response.Cookies.Add(httpcookie);
string returnURL = Request.QueryString["returnURL"];
if (returnURL == null)
{
Response.Redirect(returnURL);
}
else
Response.Redirect("Default.aspx");
}
<authentication mode="Forms">
<forms defaultUrl="Default.aspx" loginUrl="Login.aspx">
</forms>
</authentication>
<authorization>
<allow roles="Admin"/>
<deny users="*"/>
</authorization>
Thursday, June 20, 2013
Jquery Image Gallery
<script type="text/javascript" src="script/jquery.1.9.min.js"></script>
<script type="text/javascript">
var imageList;
var start = 0;
var autoImagesLoadID;
$(document).ready(function () {
$.ajax({
type: "POST",
url: "Default.aspx/galleryPhotos",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
imageList = data.d;
loadImages(imageList);
autoImagesLoad(imageList);
}
});
function autoImagesLoad(imgList) {
autoImagesLoadID = setInterval(function () {
if (start + 1 > imgList.length) {
start = 0;
}
else {
start = start + 1;
}
$("#content > div.box > div.image > img").attr("src", "upload/" + imgList[start].photoPath);
if (start % 5 == 0) {
var $divthumbs = $("#content > div.box > div.thumbs").empty().append("");
for (var i = start; i < start + 5; i++) {
if (imgList[i] && imgList[i].photoPath.length > 1) {
var $div = $("<div/>").attr("class", "thumb").attr("title", imgList[i].rowID);
var $divT = $("<div/>").attr("class", "imgthumb");
var $a = $("<a/>").attr("href", "javascript:;");
var $img = $("<img/>").attr("src", "upload/" + imgList[i].photoPath).appendTo($a);
$divT.append($a).appendTo($div);
$divthumbs.append($div);
}
}
}
$("#content > div.box > div.thumbs > div.thumb").css("background-color", "");
$("#content > div.box > div.thumbs > div.thumb[title~=" + (start + 1) + "]").css("background-color", "Blue");
}, 3000);
}
function loadImages(imgList) {
$("#content > div.box > div.image > img").attr("src", "upload/" + imgList[start].photoPath);
var $divthumbsTemp = $("<div/>");
for (var i = start; i < start + 5; i++) {
if (imgList[i] && imgList[i].photoPath.length > 1) {
var $div = $("<div/>").attr("class", "thumb").attr("title", imgList[i].rowID);
if (i == 0) {
$div.css("background-color", "Blue");
}
var $divT = $("<div/>").attr("class", "imgthumb");
var $a = $("<a/>").attr("href", "javascript:;");
var $img = $("<img/>").attr("src", "upload/" + imgList[i].photoPath).appendTo($a);
$divT.append($a).appendTo($div);
$divthumbsTemp.append($div);
}
}
$("#content > div.box > div.thumbs").empty().html($divthumbsTemp.html());
}
$("#content > div.box > div.arrowleft").click(function () {
if (start - 5 < 0)
start = 0;
else
start = start - 5;
$("#content > div.box > div.thumbs").animate({ "margin-right": "85%", height: "73px", width: "1px" }, "slow", function () {
loadImages(imageList);
});
$("#content > div.box > div.thumbs").animate({ "margin-right": "0%", height: "73px", width: "545px" }, "slow");
});
$("#content > div.box > div.arrowright").click(function () {
if (start + 5 < imageList.length)
start = start + 5;
$("#content > div.box > div.thumbs").animate({ "margin-left": "85%", height: "73px", width: "1px" }, "slow", function () {
loadImages(imageList);
});
$("#content > div.box > div.thumbs").animate({ "margin-left": "0%", height: "73px", width: "545px" }, "slow");
});
$("#content > div.box > div.thumbs").on("mouseenter", "div.thumb", function () {
start = ($(this).attr("title")) - 1;
$("#content > div.box > div.image > img").attr("src", "upload/" + imageList[start].photoPath);
$("#content > div.box > div.thumbs > div.thumb").css("background-color", "");
});
$("#content > div.box").mouseover(function () {
clearInterval(autoImagesLoadID);
});
$("#content > div.box").mouseout(function () {
autoImagesLoad(imageList);
});
});
</script>
<!--begin pbox-->
<div class="box">
<h3>Image Description</h3>
<!-- begin post -->
<div class="image"> <img src="" height="400px" width="640px" alt="" /></div>
<!-- end post -->
<div class="arrowleft"><a href="javascript:void(0)"><img src="images/left.png" alt="" /></a></div>
<div class="thumbs">
</div>
<div class="arrowright"><a href="javascript:void(0)"><img src="images/right.png" alt="" /></a></div>
<div class="break"></div>
</div>
<!--end p bbox-->
Saturday, February 9, 2013
Create User In MVC Membership
if (ModelState.IsValid)
{
MembershipCreateStatus membershipCreateStatus;
Membership.CreateUser(userRegistration.userName, userRegistration.password, userRegistration.emailID, userRegistration.securityQuestion, userRegistration.securityAnswer, true, out membershipCreateStatus);
if (membershipCreateStatus == MembershipCreateStatus.Success)
{
Roles.AddUserToRole(userRegistration.userName, "UserRole");
return RedirectToAction("Index", "Account");
}
else
{
ModelState.AddModelError("", "Registration Unsuccessful, Please Try again");
return View(userRegistration);
}
}
else
{
return View(userRegistration);
}
List Users In MVC Membership
CommonList commonList = new CommonList();
commonList.userName = "";
commonList.userList = Membership.GetAllUsers().Cast().Select(m => new UserList { userName = m.UserName, emailID = m.Email }).ToList();
Monday, January 28, 2013
Fill Dropdownlist in mvc
@Html.DropDownListFor(m => m.categoryList, new SelectList(Model.categoryList, "Value", "Text")) public IEnumerablecategoryList { get; set; } KochiDealsEntities1 db = new KochiDealsEntities1(); public IEnumerable fetchCategoryList() { var cat = (from m in db.ItemCategories select new { m.CategoryID,m.CategoryName }).AsEnumerable().Select(x => new SelectListItem { Value = x.CategoryID.ToString(), Text = x.CategoryName, Selected = true }); return cat; }
Subscribe to:
Posts (Atom)