Techaray

Shailendra Saxena's Technical Blog

How to show/hide a anchor tag on the basis of Web.config in ASP.NET

clock March 9, 2015 13:16 by author ShailendraSaxena

Hi,

In appsetting section of web.config I make element.then on Action method I wrote those property in cookie and then read it on javascript.

below is the sample code for it.

 

  $(document).ready(function () {

        var mktShow = getCookie("mktShow");
        if (mktShow != "yes") {
            $("#ss").hide();
        } else {
                var mktShowhref = getCookie("mktImagelnk");
                var mktImage = getCookie("mktImage");
                var mydiv = document.getElementById("ss");
                var aTag = document.createElement('a');
                aTag.setAttribute('href', mktShowhref);
                aTag.setAttribute('id', "sms");
                aTag.setAttribute('style', 'width: 728px;height: 90px;background-image: url('+ mktImage +');padding: 0px;display: block; margin-left: auto; margin-right: auto; margin-bottom: 10px; ');
                mydiv.appendChild(aTag);
                $("#ss").show();
        }
      
    });



How to Show Enum Dropdown List in MVC4

clock May 14, 2014 05:03 by author ShailendraSaxena

 

 

This example shows you how to create a Enum Dropdown in ASP.Net MVC4.

We need to show Sex as Male or Female in Employee Screen

Step1:

Create a Class which contains the Enumlist under a Folder Enums.

 

namespace MVCApp.Enums

{

    public class MyEnums

    {

 

        public enum Gender

        {

            Male=0,

            Female=1

        }

    }

}

Step2.

Create a Employee Model as below.

using MVCApp.Enums;

 

 

namespace MVCApp.Models

{

    public class Employee

    {

               

        public int ID { get; set; }

        public string Name { get; set; }

 

        public MyEnums.Gender Sex { get; set; }

 

        public string Post { get; set; }

 

        public decimal Salary { get; set; }

 

        public string City { get; set; }

    }

}

 

Step 3.

In Create.CSHTML define as below

<divclass="form-group">

            @Html.LabelFor(model => model.Sex, new { @class = "control-label col-md-2" })

            <divclass="col-md-10">

               @Html.DropDownListFor(model => model.Sex,newSelectList(Enum.GetValues(typeof(MVCApp.Enums.MyEnums.Gender))))

                @Html.ValidationMessageFor(model => model.Sex)

            </div>

        </div>

 



There was an error running the selected code generator: MVC Entity Framework

clock February 6, 2014 08:16 by author ShailendraSaxena

Error : There was an error running the selected code generator

 

Above error comes in case of MVC project. when you have already created a separate DAL with Entity Framework 5.0 and you are adding this DAL in another project which is made in VS2013 with EF 6.0.

 

Resolution : To resolve this error I re-create my DAL Project with EF6.0 and add the reference in my Web Project.

 



ASP.NET Web Forms V/s ASP.net MVC

clock February 4, 2014 05:03 by author ShailendraSaxena



Search

Calendar

<<  June 2017  >>
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

Archive

Tags

Categories


Visitors

FlagCounter

Flag Counter

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2017

Sign In