Friday, March 19, 2021

Session Login in c# or Cookies Login in c#

1.  Cookies


public ActionResult Login(){

    Response.Cookies["userc"].Value  = log.user_name;

    return RedirectToAction("Index");

}

public ActionResult Logout(){

    Response.Cookies["userc"].Value = "";

    return RedirectToAction("Index");

}

public ActionResult Using(){

    if  (Request.Cookies["userc"] != null && Request.Cookies["userc"].Value != ""){

            string var1 = Request.Cookies["userc"].Value;

    }

    return RedirectToAction("Index");

}


2.  Session


public ActionResult Login(){

    Session["user_id"]  = log.user_name;

    return RedirectToAction("Index");

}

public ActionResult Logout(){

    Session["user_id"] = null;

    return RedirectToAction("Index");

}

public ActionResult Using(){

    if  (Session["user_id"] != null){

            string var1 = Session["user_id"].ToString();

    }

    return RedirectToAction("Index");

}









Wednesday, March 17, 2021

Floating Menu css property

 

.dropdown-menu{

position: absolute;

top: 100%;

z-index: 1000;

background: #ff0404ad;

}

Friday, March 12, 2021

Image Hover effect

/* image over effect *
img {
    ....:..;
    ....:..;
    overflowhidden;
}

img:hover{
    -webkit-transformscale(1.3);
    transformscale(1.3);
}

Responsive Image in container

Responsive Image in div  

img {
  width: 100%;
  height: 300px;
  object-fit: cover;
  object-position: bottom; 
}  

Thursday, March 11, 2021

Scroll Up and Scroll Down In JavaScript

//Scroll Up and Scroll Down In JavaScript

var scroll_y = document.getElementById("div_top_header");
// Initial state
var scrollPos = 0;
// adding scroll event
window.addEventListener('scroll'function () {
    // detects new state and compares it with the new one
    if ((document.body.getBoundingClientRect()).top > scrollPos){
        // document.getElementById('info-box').setAttribute('data-scroll-direction', 'UP');
        console.log('UP');
        scroll_y.style.display = "block";
    }
    else{
        // document.getElementById('info-box').setAttribute('data-scroll-direction', 'DOWN');
        console.log('down');
        scroll_y.style.display = "none";
    }
        // saves the new position for iteration.
    scrollPos = (document.body.getBoundingClientRect()).top;
});

Linq Expression syntax for where condtion in linq

(Expression<Func<T, bool>> filter)