Thursday 28 March 2013

How To Shown Selected menu in MVC 4

This article explaining for how to create menu's in mvc and how to set selected menu shown .


First add this styles in your css style sheet


ul#menu
{
    font-size: 1.3em;
    font-weight: 600;
    margin: 0 0 5px;
    padding: 0;
    text-align:left;
    position:absolute;
}

ul#menu li
{
    display: inline;
    list-style: none;
    margin-left: 22px;
    float:left;
}


ul#menu li a
{
    background: none;
    color: Black;
    text-decoration: none;
    font-family: Arial;
}
.select,#menu li a:hover
{   
    
    color:White ;
    text-decoration: underline;
    cursor:pointer;
}

.select
{       
    color:White ;
    background-color:#F41818 !important;
    text-decoration: underline;
    cursor:pointer;
    padding-left:0px;
}

Then add this razor code  in your page and must call your css file in this page head tag  inside .
for(Please style.css is mine .But you must  provide your css file only)

<head>

    <link href="~/Content/style.css" rel="stylesheet" />

</head>




 <div style="width: 100%; padding-bottom: 20px; margin-left: -7%; margin-top: 14%">
                    <br />
                    <ul id="menu">
                        <li id="home">@Html.ActionLink("Home", "Index", "Home")</li>
                        <li id="About">@Html.ActionLink("Discussions", "About", "Home")</li>
                        <li id="Compliance">@Html.ActionLink("Compliance", "ManageCompliance", "Compliance")</li>
                        <li>@Html.ActionLink("Reports", "About", "Home")</li>
                        <li>@Html.ActionLink("Documents", "Contact", "Home")</li>
                        <li id="FinancialCompliance" >@Html.ActionLink("Compliance", "ViewFinancialCompliances", "FinancialCompliance")</li>
                        <li id="Team">@Html.ActionLink("Team", "Contact", "Home")</li>
                        <li id="Admin">@Html.ActionLink("Admin", "Admin", "Admin")
                        </li>
                    </ul>
                </div>

Now the above  menu is showing like when ordinary showing menu and shown  hover menu


okay .that finished .

Now you want  selecting  menu is showing  static .So put the below code in your header tag inside

 <script type="text/javascript">

        $(document).ready(function () {

            var url = window.location.pathname;
            var home = "Home/Index";
            var About = "Home/About";
            var Compliance = "Compliance/ManageCompliance";//Put your page url 
            var Admin = "Admin/Admin";
            var EditCompliance = "Compliance/EditCompliance";//Put your page url 
            var AddCompliance = "Compliance/AddCompliance";//Put your page url 
            var Team = "/Home/Contact";
            var AddSchool = "Admin/AddSchool";//Put your page url 
            var AddDistrict = "Admin/AddDistrict";//Put your page url 
            var EditSchool = "Admin/EditSchool";//Put your page url 
            var EditDistrict = "Admin/EditDistrict";//Put your page url 
            var ViewFinancialCompliance = "FinancialCompliance/ViewFinancialCompliances"//Put your page url 
            var AddFinancialCompliance = "FinancialCompliance/AddFinancialCompliance"//Put your page url 
         
            if (url.indexOf(home) > -1) {
                $("#home").addClass("select");
                $(".select a:hover").addClass("select").show();
            }
            else if (url.indexOf(ViewFinancialCompliance) > -1) {
                $("#FinancialCompliance").addClass("select").show();
            }
            else if (url.indexOf(AddFinancialCompliance) > -1) {
                $("#FinancialCompliance").addClass("select").show();
            }
            else if (url.indexOf(About) > -1) {
                $("#About").addClass("select").show();
            }
            else if (url.indexOf(Compliance) > -1) {
                $("#Compliance").addClass("select").show();
            }
            else if (url.indexOf(AddCompliance) > -1) {
                $("#Compliance").addClass("select").show();
            }
            else if (url.indexOf(EditCompliance) > -1) {
                $("#Compliance").addClass("select").show();
            }
            else if (url.indexOf(Admin) > -1) {
                $("#Admin").addClass("select").show();
            }
            else if (url.indexOf(AddSchool) > -1) {
                $("#Admin").addClass("select").show();
            }
            else if (url.indexOf(AddDistrict) > -1) {
                $("#Admin").addClass("select").show();
            }
            else if (url.indexOf(EditSchool) > -1) {
                $("#Admin").addClass("select").show();
            }
            else if (url.indexOf(EditDistrict) > -1) {
                $("#Admin").addClass("select").show();
            }
            else if (url.indexOf(Team) > -1) {
                $("#Team").addClass("select").show();
            }
            else {
                $("#home").addClass("select").show();
            }

        });
        
    </script>


Now you can see selecting  menu is selected.

for see below image .Its shown as  selecting menu is selected


But you like ,you  can  change your font color and etc  in css



Tuesday 26 March 2013

Increase Session Time Out(Automatic Log off problem )in asp.net

Add this code in your webconfig


<system.web>
    <authentication mode="Forms">
          <forms timeout="50"/>
    </authentication>

    <sessionState timeout="60"  />
</system.web>
And please check this same issue with best answers

Sunday 24 March 2013

Types of SQL Keys




  • Super Key

    Super key is a set of one or more than one keys that can be used to identify a record uniquely in a table.Example : Primary key, Unique key, Alternate key are subset of Super Keys.
  • Candidate Key

    A Candidate Key is a set of one or more fields/columns that can identify a record uniquely in a table. There can be multiple Candidate Keys in one table. Each Candidate Key can work as Primary Key.
    Example: In below diagram ID, RollNo and EnrollNo are Candidate Keys since all these three fields can be work as Primary Key.
  • Primary Key

    Primary key is a set of one or more fields/columns of a table that uniquely identify a record in database table. It can not accept null, duplicate values. Only one Candidate Key can be Primary Key.
  • Alternate key

    A Alternate key is a key that can be work as a primary key. Basically it is a candidate key that currently is not primary key.
    Example: In below diagram RollNo and EnrollNo becomes Alternate Keys when we define ID as Primary Key.
  • Composite/Compound Key

    Composite Key is a combination of more than one fields/columns of a table. It can be a Candidate key, Primary key.
  • Unique Key

    Uniquekey is a set of one or more fields/columns of a table that uniquely identify a record in database table. It is like Primary key but it can accept only one null value and it can not have duplicate values. For more help refer the article Difference between primary key and unique key.
  • Foreign Key

    Foreign Key is a field in database table that is Primary key in another table. It can accept multiple null, duplicate values. For more help refer the article Difference between primary key and foreign key.
    Example : We can have a DeptID column in the Employee table which is pointing to DeptID column in a department table where it a primary key.
  • Wednesday 20 March 2013

    Create FaceBook Like button in my application

    This article give highly proper code
    1: Include the JavaScript SDK on your page once, ideally right after the opening <body> tag.


    <div id="fb-root"></div>
    <script>(function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>


    2: Place the code for your plugin wherever you want the plugin to appear on your page.

    <div class="fb-like" data-send="true" data-width="450" data-show-faces="true"></div>


    Friday 15 March 2013

    Create dropdownList in MVC with EntityFrameWork


    This article will give's for   how to  create dropdownlist in mvc with Entity Frame Work?and how to  get the database table values then bind dropdownlist 

    Create one class file(model)  and create  one property  for datatype is SelectList  in the class file for  look below way


    public class RegisterModel
        {     
            public SelectList SchoolList { get; set; }     
            public int ScoolId { get; set; }
        }

    This above model property is using for assign database return values then bind the property values in  dropdownlist . You can understand back


    Next,Just call  database table(My Table name is School) values in one method for

    SchoolBriefcaseEntities datamodel = new SchoolBriefcaseEntities();// It is my Entity class  object 


    public IList<School> LoadSchools()
            {
                return datamodel.Schools.ToList();
            }


    The above LoadScools method was  return some SchoolId and SchoolName(Its both of  my table column name's).



    Then call the LoadSchool method for 


    public SelectList BindSchools()
            {            
                IList<School> schools = LoadSchools(); 
                return new SelectList(schools, "SchoolId", "SchoolName"); 
            }

    Then Just call  that RegisterModel and assign the database return values to model class(SchoolList) property  in inside of our Controller ActionResult  method  for 


    [AllowAnonymous]
            public ActionResult Register()
            {
                RegisterModel registerModel = new RegisterModel();// It is Modelclass 
                registerModel.SchoolList = BindSchools();// assign the database return values in model class(SchoolList) property 
                return View(registerModel);
            }


    Then, Right click inside of   the controller action result  method (Register)  -->Click Add View-->click the checkbox for create strongly _type view -->Select your modelclass in below dropdown (Now we have RegisterModel class .So we  choose  RegisterModel in this dropdownlist)--> Click Add Button .


    Now the View(razor ) is created . you can see this view page in your solution explorer  .Its display like for 



    @model SchoolBreifcase.Models.RegisterModel
    @{
        ViewBag.Title = "Register"; 
    }
    <h2>
        Register</h2>
    @using (Html.BeginForm())
    {
        @Html.ValidationSummary(true)

        <fieldset>
            <legend>RegisterModel</legend>              
                <div class="editor-label">
                    @Html.LabelFor(model => model.ScoolName)
                </div>
                <div class="editor-field">
                    @Html.DropDownListFor(m => m.ScoolId, Model.SchoolList, "Select")
                    @Html.ValidationMessageFor(model => model.ScoolName)
                </div>      
            <p>
                <input type="submit" value="Create" />
            </p>
        </fieldset>
    }
    <div>
        @Html.ActionLink("Back to List", "Index")
    </div>
    @section Scripts {
        @Scripts.Render("~/bundles/jqueryval")
    }


    The above green line is called the RegisterModel class property(SchoolName). But we have already assigned some  values in this property  from database in controller . So now the dropdownlist is display our database values . you can get dropdown selected value in  ScoolId  property


    If you have any doubt , then please comment or message me . 

    My Mail Id is : 04RameshRajendran04@gmail.com                                   //You can send mail 

    FaceBook page:https://www.facebook.com/DotnetSolutionsblogspotin      //You can post in wall 

    or Comment please !







    Monday 4 March 2013

    Change FOREIGN KEY Reference in sql

    try this sample way for

    the
    ALTER TABLE Dealpool ADD CONSTRAINT fk_Dealpool_Agent FOREIGN KEY (AgentId)

    //It is a reference table column

    REFERENCES Agent(AgentId) // It is a referring  table primary key


    Below final code is .

    ALTER TABLE Dealpool ADD CONSTRAINT fk_Dealpool_Agent FOREIGN KEY (AgentId)    REFERENCES Agent(AgentId)

    How to reduce angular CLI build time

     Index: ----- I am using angular cli - 7 and I am going to tell how to reduce the build time as per my knowledge. Problem: -------- Now the ...