Friday, 4 January 2019

IQ

How to pass class a parameter to wcf service.
Main purpose of Data contract in wcf
Difference between wcf and web service
how to implement security in wcf.
Default access modifier for constructor
Default access modifier for class


Howto get Employee count without duplicate name..
 class Program
    {
        static void Main(string[] args)
        {
            List<Person> emplist = new List<Person>(){
               new Person(){ FirstName = "A", LastName = "A"},
               new Person(){ FirstName = "B", LastName = "B"},
               new Person(){ FirstName = "A", LastName = "A"}
            };

            var lstemplo = emplist.GroupBy(aa => new { aa.FirstName, aa.LastName }).Select(bb => new Person { FirstName = bb.Key.FirstName, LastName = bb.Key.LastName }).ToList();
            Console.WriteLine(lstemplo.Count());
            Console.ReadLine();

        }
    }

    public class Person
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }

What is Difference between Html.Partial and Html.RenderPartial in MVC?

Html.Partial returns a stringHtml.RenderPartial returns void.
- We can store the output of Html.Partial in a variable/able to return from function.
- In Html.RenderPartial, we can’t result void.(ie.,directly writing to the output stream so it was bit faster than html.partial())

Html.RenderPartial
1. This method result will be directly written to the HTTP response stream means it used the same TextWriter object as used in the current webpage/template.
2. This method returns void.
3. Simple to use and no need to create any action.
4. RenderPartial method is useful when the displaying data in the partial view is already in the corresponding view model.For example : In a blog to show comments of an article, we would like to use RenderPartial method since an article information with comments are already populated in the view model.
@{Html.RenderPartial("_Comments");}
5. This method is faster than Partial method since its result is directly written to the response stream which makes it fast.

Html.Partial
1. Renders the partial view as an HTML-encoded string.
2. This method result can be stored in a variable, since it returns string type value.
3. Simple to use and no need to create any action.
4. Like RenderPartial method, Partial method is also useful when the displaying data in the partial view is already in the corresponding view model. For example: In a blog to show comments of an article, you can use Partial method since an article information with comments are already populated in the view model.
@Html.Partial("_Comments")

Get Selected Checkboxes Value Using jQuery


<script type="text/javascript">
    $(document).ready(function() {
        $(".btn").click(function() {
            var colors = [];
            $.each($("input[name='color']:checked"), function() {
                colors.push($(this).val());
            });
            alert("My favourite colors are: " + colors.join(", "));
        });
    });
</script>

How to change the Master page dynamically for a content page in ASP.NET?

protected void Page_PreInit(object sender, EventArgs e)
{
  this.MasterPageFile = "~/MasterPage2.master";
}

context.Configuration.LazyLoadingEnabled = false;


No comments:

Post a Comment