Tuesday, December 18, 2018

.Net Core INSTRUMENTATION_KEY is not set error

When you are debugging eShopOnContainers  on Visual Studio 2017 for the first time and when this build error throws INSTRUMENTATION_KEY  variable is not set.

goto   docker-compose.override.yml

Replace this line
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
to
- ApplicationInsights__InstrumentationKey=//${INSTRUMENTATION_KEY}

1. Make sure you set 4GB of Memory and  CPus -3 in Docker settings ->Advanced


Thursday, October 27, 2016

Zurb Foundation Tab not working after Post-deep linking error

Tab's are really great to display different content.
I ran into an issue where i have 3 tabs and 3 different contents inside a div.When i click on Save button after the post the page displays but when you click on other tabs.it will throw deep-linking error.

In order to solve this just add this in the Save button's post method

 $(document).foundation('reflow');



$.post($("#frmSetting").attr('action'), $("#frmSetting").serialize(), function (result) {
                    $('#DataContainer').html(result);
                    $(document).foundation('reflow'); // tab after saving opens other tab
                 
                }, "html");

Thursday, September 10, 2015

View to Model

To get the value from view page to model
 use the keyword name  in the textbox or any html controls like this
name="comment"

           
< input type="text" class="input-medium" id="website" name="website" data-val="true" data-val-required="*">

< textarea class="input-medium" id="comment" rows="3" name="comment" data-val="true" data-val-required="*">< /textarea>
namespace TestWebProject.Models
{
    public class ContactModel
    {
        public string Name { get; set; }
        public string Email { get; set; }
        public string Website { get; set; }
        public string Comment { get; set; }
    }
}
To connect to controller add the form method as Post
                   < form class="form-horizontal" method="post" >

In controller it will take automatically
        [HttpPost]
        public ActionResult Contact(ContactModel model)

Tuesday, December 16, 2014

Tuesday, December 2, 2014

WCF Windows Communication foundation

Windows communication Foundation and the important


Attributes used in WCF are

1.[DataContract] Used in the model class Customer information in this eg: Above the Class name you have to use this attribute.
[DataContract]
public class Customer
{
[DataMember]
public int Custid {get;set}
[DataMember]
public string CustName {get;set}
}

private List custList=new List()
{
new Customer()={Custid= 1,CustName ="Win"}
}

public List CustomerList
{
  get
  {
     return custList;
  }
}
2. Properties of the class are DataMembers
3.[ServiceContract] is an attribute used above the Interface
  [ServiceContract()]
    public interface ICustomer
    {
        [OperationContract]
        List< Customer > GetAllCustomerDetails();

        [OperationContract]
        Customer GetCustomer(int Id);
             

    }
4. [OperationContract] attributes above the interface methods. Interface methods are public by default 5. [WebGet] and .[WebInvoke] attributes can be used above the [OperationContract]
    [ServiceContract()]
    public interface ICustomer
    {
 [WebGet(UriTemplate = "Customer")]
        [OperationContract]
        List< Customer > GetAllCustomerDetails();
       [WebGet(UriTemplate = "GetCustomer?id={id}")]
        [OperationContract]
        Customer GetCustomer(int Id);
         [WebInvoke(Method = "POST", UriTemplate = "CustomerPOST")]
        [OperationContract]
        void AddCustomer(Customer newCust);    

    }

Step by step process here http://www.wcftutorial.net/How_to_create_RESTful_Service.aspx

Json structure

JSON  is JavaScript Object Notation
Its human readable text to transmit Data objects.

{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}
The same text expressed as XML:
< menu id="file" value="File">
  < popup>
    < menuitem onclick="CreateNewDoc()" value="New">
    < menuitem onclick="OpenDoc()" value="Open">
    < menuitem onclick="CloseDoc()" value="Close">
  < /menuitem>
< /popup> < /menu>

1. And this can be accessed by javascript by calling JSON.parse(
var p = JSON.parse(menu);
2. Calling JSON from Jquery by using $.getJSON
$.getJSON( "ajax/test.json", function( data )
{
  var items = [];
  $.each( data, function( key, val ) 
  {
    items.push( "< li id='" + key + "'>" + val + "</ li>" );
  });
  $( "< ul/>", 
  {
    "class": "my-new-list",
    html: items.join( "" )
  }).appendTo( "body" );
}
);

Ref:https://jquery.org/

Calling Class, Id ,Element from jQuery

We can Select any Elements(Headers like h1,h2, paragraphs like p) by using JQuery
jQuery function can be written as

$(function)
{
});
or
$(document).ready(function()
{});

1. So in this example we can hide the header h2 in the html file when the button is clicked.

$(document).ready(function()
{
   $("button").click(function()
    {
                   $("h2").hide();
    });
});

if there is more than one element,say h2 headers are more than one time used in the html it will hide all the h2.


2. Call the html element with their id by using "#" $("#btnName")

< !DOCTYPE html>
< html>
< head>
< script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">< /script>
< script>
$(document).ready(function(){
  $("#btnName").click(function(){
    $("#test").hide();
  });
});
< /script>
< /head>
< body>

< h2>This is a heading
< p>This is a paragraph.
< p id="test">This is another paragraph.
< button id="btnName">Click me

< /body>
< /html>
3. Call the html element's class by using "."

$(document).ready(function(){
  $("button").click(function(){
    $(".h2Css").hide();
  });
});

< h2 class="h2Css">This is a heading

All these examples are at  w3Schools.com.Please visit the website.