Monday 4 November 2013

AngularJS Simple Sample

I already gave some information about angularJs here :


First you surely need to read the above article , then come here ......


Okay cool ! Now we will go to build simple one angularJs Application .


My sample application created for Web-application , But you can do any type of application(windows,MVC Project) ,etc......

First add one index page in my application  and you need to just copy past the below code but , I will explain further details .

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Index.aspx.cs" Inherits="Index" %>

<!DOCTYPE html>

<html ng-app>
<head runat="server">
    <title></title>
    <script src="Scripts/angular.min.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <label>Name:</label>
            <input type="text" ng-model="Name" placeholder="Enter a name here">
            <label>{{Name}}</label>           
        </div>
    </form>
</body>
</html>




The Above Green color codes are must important ..

where..

ng-app  - This keyword use for  Define Angular Js .

 <script src="Scripts/angular.min.js"></script> - Call angularJs in the Current Page .

 ng-model="Name"  - This is AngularJS Model Property (Just assume MVC Model property)

{{Name}} - Binding the model property value in a label . (Just Assume pass the MVC Model Property values to view)


Results are :

If you type any value in the textbox , It's display the below label( Like OnTextChanged Event process)

Okay ! Now you can create simple  angularJS application on yourself ,


AngularJS tutorial

What Is AngularJS ?

AngularJS is a Javascript MVC framework created by Google to build properly architectured and maintenable web applications.

Why AngularJS?

AngularJS is a MVC framework that defines numerous concepts to properly organize your web application. Your application is defined with modules that can depend from one to the others. It enhances HTML by attaching directives to your pages with new attributes or tags and expressions in order to define very powerful templates directly in your HTML. It also encapsulates the behavior of your application in controllers which are instanciated thanks to dependency injection. Thanks to the use of dependency injection, AngularJS helps you structure and test your Javascript code very easily. Finally, utility code can easily be factorized into services that can be injected in your controllers. Now let’s have a closer look at all those features.


Build Simple AngularJs Application :

First You need to Install AngularJs Package in your application .It's not a big work , Just simple go and right click the Project In Solution explorer>Click  Manage NuGet Package  >Select Online tag > type AngularJs In the Search box >Then Download and install the AngularJs .

See this below Image for install angularJs in the Project 


If you done this process then you can see some javascript files in your Script Folder 

See this below Image 


Okay now we are finished of angularJs installation in our application . 


Now We will go to Build simple angularJs application (click the link )....... 


Tuesday 6 August 2013

Add values to SelectList in MVC C#

 SelectList adequateList = new SelectList(new[]
             {
                new { Id = "1", Name = "Yes" },
                new { Id = "0", Name = "No" },       
             }, "Id", "Name");

Tuesday 25 June 2013

How to find single value from string in c#

         You can use this code for  find single value from string


        const string stringValue = "1,16,12,113";
            string result = "";
            const string yourValue = "1"; //Assiged the user input value
            string[] arr = stringValue.Split(new char[] { ',' });//Convert string to string array
            foreach (string value in arr)
            {
                if (value == "" + yourValue + "") // condition checked for matching your value  in string array
                {
                    result = value; //assign the matched value
                    break; // then go to out side of for each
                }
            }
            string finalResult = result; //finally assigend the matching value


My above code is working fine .but i used foreach ,it's not a good performance ,so we can use findall
see below code and try this

const string stringValue = "1,16,12,113";
string finalValue = "";
const string yourValue = "1"; //Assiged the user input value
string[] arr = stringValue.Split(new char[] { ',' });//Convert string to string array
var results = Array.FindAll(arr, s => s.Equals(yourValue));//if your value there ,then we assigned that value in array
if (results.Length != 0)
    {
      finalValue = results[0];//finay we got a value
    }

Convert string to string array in c#

here is a simple example for convert string to string array


            string values= "1,16,12,113";
            string[] arr = values.Split(new char[] { ',' }); //Convert string to string array using split 

Monday 24 June 2013

How to create a simple WPF application

In Visual Studio 2008 OR any 


  • Open Visual Studio 2008 and choose "File", "New", "Project..." in the main menu. Choose "WPF Application" as project type.
  • Choose a folder for your project and give it a name. Then press "OK"


  • Visual Studio creates the project and automatically adds some files to the solution. A Window1.xaml and an App.xaml. The structure looks quite similar to WinForms, except that the Window1.designer.cs file is no longer code but it's now declared in XAML as Window1.xaml


  • Select the Button and switch to the event view in the properties window (click on the little yellow lightning icon). Doubleclick on the "Click" event to create a method in the codebehind that is called, when the user clicks on the button.

Note: If you do not find a yellow lightning icon, you need to install the Service Pack 1 for VisualStudio on your machine. Alternatively you can doubleclick on the button in the designer to achieve the same result.

  • Visual Studio automatically creates a method in the code-behind file that gets called when the button is clicked.
private void button1_Click(object sender, RoutedEventArgs e)
{
    textBox1.Text = "Hello WPF!";
}


  • The textbox has automatically become assigned the name textBox1 by the WPF designer. Set text Text to "Hello WPF!" when the button gets clicked and we are done! Start the application by hit [F5] on your keyboard.





Saturday 8 June 2013

difference between margin and padding in css

padding is the space between the content and the border, whereas margin is the space outside the border. Here's an image I found from a quick Google search, that illustrates this idea.



Monday 8 April 2013

Set the startup page in an ASP.NET MVC 4


Go to your project's properties and set the start page property.

1) Go to the project's Properties
2) Go to the Web tab
3) Select the Specific Page radio button
4) Type in the desired url in the Specific Page text box

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 ...