How to Start with Materialize CSS

The beginners may have some difficulties about how to start and learn the materialize design.  Here is a simple steps to learn and quick start with materialize design.

  1. Add the Following link

<!--Import Google Icon Font-->
					<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
					<link href="~/css/materialize.min.css" rel="stylesheet" />
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<span 				data-mce-type="bookmark" 				id="mce_SELREST_start" 				data-mce-style="overflow:hidden;line-height:0" 				style="overflow:hidden;line-height:0" 			></span>			<link href="~/css/ClientStyles/main.css" rel="stylesheet" /><span 				data-mce-type="bookmark" 				id="mce_SELREST_end" 				data-mce-style="overflow:hidden;line-height:0" 				style="overflow:hidden;line-height:0" 			></span>
<style>
.caret {
border-top: 0px !important;
}
</style>

2. Add following line of html

<div class="row">
<form class="col s12">
<div class="row">
<div class="input-field col s6">
<input placeholder="Placeholder" id="first_name" type="text" class="validate">
<label for="first_name">First Name</label></div>
<div class="input-field col s6">
<input id="last_name" type="text" class="validate">
<label for="last_name">Last Name</label></div>
</div>
<div class="row">
<div class="input-field col s12">
<input disabled value="I am not editable" id="disabled" type="text" class="validate">
<label for="disabled">Disabled</label></div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="password" type="password" class="validate">
<label for="password">Password</label></div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="email" type="email" class="validate">
<label for="email">Email</label></div>
</div>
<div class="row">
<div class="col s12">
This is an inline input field:
<div class="input-field inline">
<input id="email" type="email" class="validate">
<label for="email" data-error="wrong" data-success="right">Email</label></div>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<select>
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<label>Select Project</label></div>
<div class="input-field col s6">
<select>
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<label>Select Percentage</label></div>
</div>
<div class="row">
<div class="col s6">
<button class="btn waves-effect waves-light" type="submit" name="action">
Submit
<i class="material-icons right">send</i>
</button></div>
<div class="col s6">
<button class="btn waves-effect waves-light" type="submit" name="action">
Cancel
<i class="material-icons right">send</i>
</button></div>
</div>
</form></div>

3. Add following script


@section Scripts{
<script>
$(document).ready(function () {
$('select').material_select();
});

</script>
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
 <script src="~/js/materialize.min.js"></script>
}

Design sample of above materialize css will look like

Screenshot-2017-12-30 - Hospitality UI

 

 

More Details Click Here

How to get the session value and show into view in asp.net Core?

One way for this is:  Get the session value and store it to View Bag in the controller and then show the view bag value to the View. There are mainly two steps.

  1. In Controller, Firstly get the value of session to the view bag by writing these code
 ViewBag.OrdStatus = HttpContext.Session.GetString(SessionHandler.m_sessionOrderStatus); 

 

2. In the View, write following line to the appropriate division where you want to show the session value.

<p> @ViewBag.OrdStatus  </p>

How to set and get the session value in asp.net core.

The Microsoft.AspNetCore.Session package provides middleware for managing session state.

  1. Add the following heightened line in your Startup.cs

public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
// Adds a default in-memory implementation of IDistributedCache
 services.AddDistributedMemoryCache();
services.AddSession(options =>
{
// Set a time for session
options.IdleTimeout = TimeSpan.FromSeconds(200);
options.Cookie.HttpOnly = true;
});
}

public void Configure(IApplicationBuilder app)
{
app.UseSession();
app.UseMvcWithDefaultRoute();
}
  1. Following line of code is needed to set the session value.

public class HomeController : Controller
{
const string SessionStoreName = "_StoreName";
const string SessionStoreID = "_StoreID";

public IActionResult Index()
{
// Requires using Microsoft.AspNetCore.Http
 HttpContext.Session.SetInt32(SessionStoreID, 3);
 HttpContext.Session.SetString(SessionStoreName, "ABC Store");
return RedirectToAction("SessionStore");
}
  1. To get the session value

public IActionResult SessionStore ()
{
var storename = HttpContext.Session.GetString(SessionStoreName);
var storeID = HttpContext.Session.GetInt32(SessionStoreID);
return Content($"Store Name: \"{ storename }\",Store ID: \"{ storeID}\"");
}
Aside

SQL Server Interview Questions and Answers for Mid Level

1.Write the script to create Table.

Answer:

CREATE TABLE Test
(
ID int,
LastName varchar(255),
FirstName varchar(255),

Address varchar(100),

);

2. What is Primary Key Constraint?

Answer:

The PRIMARY KEY constraint uniquely identifies each record in a database table. It must contain unique values and must not contain null values. Most of the tables should have the Primary key but there exists only one Primary Key for one table. Primary key does not contain null value. Primary Key has Unique Cluster Index by default.

  1. What is Foreign Key Constraint?

Answer:

A FOREIGN KEY in one table points to a PRIMARY KEY in another table. There can exist multiple Foreign Key and Foreign Key may have null values. The FOREIGN KEY constraint prevents invalid data from being inserted into the foreign key column because it has to be one of the values contained in the table it points to.

 Reference

  1. What is Unique Constraint?

Answer:

The UNIQUE constraint uniquely identifies each record in a database table. Unique Constraint and Primary Key both provides the uniqueness of data in database table. There can be multiple Unique Key in Table but only One Primary Key. Primary Key itself has automatically defined Unique Constraint on it. Unique key can contain maximum of one null value where as primary does not.

  1. How Union and Union All works in SQL server?

Answer:

Union gives the record only once if it occurs several times but Union All gives the record as several time that occurs in the table. Means that Union gives the distinct record where as Union All allows duplicate.

e.g.        Table 1

 ID Student Name
1 Ram
2 Shyam
3 Hari

Table 2

ID Student Name
1 Ram
2 Shyam
3 Hari
1 Ram
3 Shyam

Union Result

ID Student Name
1 Ram
2 Shyam
3 Hari

Union All Result

ID Student Name
1 Ram
2 Shyam
3 Hari
1 Ram
3 Shyam
  1. What are SQL Join?

Answer:

Inner Join: If we need Common records from both the tables we use Inner Join.

Outer Join: when we need the common and uncommon record from both the table outer join is used. An outer join is of two type on the basis of the unmatching record of which table is needed.

Left Outer Join: This gives all the record of the Left table and common record of the right table. Right Outer Join: This gives all the record of the Right table and common record of the left table.

Full Join: It gives all the record of both tables.

 7. Suppose you have the script of one database for one client and you need to create the same database for another client for same project deployment. How you ensure there is an exact same database, there is no mismatch of the table, table name, columns and constraints in both the Database?

Answer:

By checking the Number of Tables, Number of Columns, Number of Constraints, Table Name etc we can ensure that there is no mismatch of database creation if there is anything missed we can find out what is missing with the help of it.

Query for Number of Table Count

select COUNT(* ) from INFORMATION_SCHEMA.TABLES

Query for Number of Column count

select COUNT(* ) from INFORMATION_SCHEMA.COLUMNS

Query for Number of Constraint Count

select COUNT(* ) from INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE

e.g.

If there is one table creation missing then running following below query in both database and comparing each other, we can find out which table is missing. This will give the name list of table in the database.

select TABLE_NAME from INFORMATION_SCHEMA.TABLES

  1. How many types of Function exists in SQL server explain with example?

Answer:

There are two types of SQL Function

  1. SQL Aggregate Functions

It returns a single value, calculated from values in a column.

Some of the Aggregate SQL Function are

AVG() – Returns the average value

COUNT() – Returns the number of rows

FIRST() – Returns the first value

LAST() – Returns the last value

MAX() – Returns the largest value

MIN() – Returns the smallest value

SUM() – Returns the sum

   2. SQL Scalar functions

SQL Scalar functions return a single value, based on the input value.

Some of the SQL Scalar Functions are

UCASE() – Converts a field to upper case

LCASE() – Converts a field to lower case

MID() – Extract characters from a text field

LEN() – Returns the length of a text field

ROUND() – Rounds a numeric field to the number of decimals specified

NOW() – Returns the current system date and time

FORMAT() – Formats how a field is to be displayed

  1. What is Difference Between Store Procedure and Function?

Answer:

– A Stored Procedure can return zero, single or multiple values. But, a function must return a single value.

– A Stored Procedure can have both input and output parameters whereas Functions can have only input parameters.

– Functions allow only a SELECT command whereas a Stored Procedure allows SELECT and other DML commands (INSERT, UPDATE and DELETE).

– A Stored Procedure can call a function, but a function can’t call a Stored Procedure.

– A Stored Procedure can use the try-catch block to handle exceptions. But try-catch is not allowed in functions.

– SQL transactions can be used in Stored Procedures but not in Functions.

  1. What is SQL Aliases?

Answer:

Aliases are used to give database Table Name or Table Column Name as Temporary Name. It is used to make column Name more readable.

SELECT ColumnName AS AliasName
FROM TableName;

ASP.Net Interview Question and Answers for Mid Level

 1. What are the asp.net page life cycle, name cycle?

Answer:

  1. PreInit()
  2. Init()
  3. InitComplete()
  4. PreLoad()
  5. Load()
  6. LoadComplete
  7. PreRender()
  8. Render()
  9. Unload()

2. What are the different Types of ASP.Net Validation Controls?

Answer:

RequireFieldValidator: validates for require filed or user input

RangeValidator: it validates the range of input filed like (0-9), (A-Z), (100-2000)

CompareValidator: it is used to compare the input control value with certain fixed value or another control value.

RegularExpressionValidator: it is use to express the input value as in required format or expression i.e. for formatting of phone number (e.g. 402-345-2344), date time format etc.

CustomValidator: it is used to customize the validation logic as needs of application logic.

      Validation Summary: displays all error message of validation controls on page.

3. What are the various way to send content from one page to another page?

Answer:

Server.Transfer()

Response.Redirect()

WebClient.DowloadFile()

4. What is difference between Server.Transfer() and Response.Redirect() and which is best?

Answer:

In case of Response.Redirect(), a new request is generated from client-side for redirected page. It’s a kind of additional round trip. As new request is generated from client, so the new URL is visible to user in browser after redirection.

While in case of Server.Transfer(), a request is transferred from one page to another without making a round trip from client. For the end user, URL remains the same in browser even after transferring to another page.

Reference

5. Why Html Helper prefer than Asp Control?

Answer: The reason of preferring Html helper is light weight though these are like ASP Controls.

6. What is the difference between Custom Control and User Control?

Answer:

Custom control are compiled code e.g: DLL. These are complex to create than User Controls and can easily added in toolbox. These can be used in multiple project with drag and drop approach.

The user controls i.e. (ascx) are like design pages i.e. (aspx). These are comparatively easy to create than custom control and are tight coupled with respect to code and UserInterface. These can be used in multiple project with copy and paste method.

7. What is Global.aspx file and purpose of it?

Answer:

Global.asax is Asp.net Application File. It is located under App_Start Folder.

Main Purpose of it is to place the Application Level code such as Application start, Application End, Session Start, Session End and Application Error handle.

Main Events fired in Global.asax file are

 Application_Init:  fires for application initialization for the very first time.

Application_Start: fires when application starts.

 Session_Start: fires when user session starts.

Application_Error:fire when there occurs error in application.

Session_End: fire when user session ends.

Application_End: fire at the time of application end or timeout

8. What are the Type of Authentication available in ASP.net?

Answer:

Windows Authentication:

Form Authentication:

Passport Authentication:

9. What are Session State Mode in Asp.net?

Answer:

In-Proc:

State Server:

SQLServer:

Custom

Off

10. What are session state management process in Asp.net?

    Answer:

In-Proc: Stores the session in Web server Memory.

Out Proc: Stores the session in different external server either in State Server or SQL Server.

11. What is Difference between Session.Abandon() and Session.Clear()?

 Answer:

Session.Abandon(): Session.Abandon() destroy the running session with firing of Session_End event from Global.asax file. It releases the Session State Object and its items to free resources. 

Seesion.Clear(): It only clears the session object’s data and set value to null without killing session. Resource becomes reserved with null value.

12. What are the different Types of Catching inAsp.net?

Answer:

There are 3 types of catching.

OutPut Catching

Data Catching

Fragment Catching

13. Can we have web application running without web.config file?

Answer:YES

14. Can we have multiple webconfig file in Asp.net Application?

Answer:Yes

15. Is it possible to create web application with Asp.net webforms and MVC?

Answer:YES

We can create the hybrid application of Webforms and MVC by using following assembly references.

System.Web.MVC

System.Web.Razor

System.ComponentModel.DataAnnotations

16. Write a sample code to send email from Asp.net Application.

Answer:

MailMessage mailMsg=new MailMessage();

mailMsg.From=”sender@gmail.com”;

mailMsg.To=”receiver@gmail.com”;

mailMsg.Subject=”Email sending test”;

mailMsg.Body=”Email testing.”;

SmtpMail.SmtpServer=”Localhost”;

Smtp.Send(mailMsg);

17. What is the good practice for implementation of validation in Asp.net?

Answer:

Client Side validation is best way to validate data in Asp.net application. Its Benefits are.

-Low network traffics.

-Save Server Resources.

-Fast Response

18. What are the differences between WebConfig and Machine Config file?

Answer:

WeConfig File: It is specific to web application. There can have multiple web config file into an application.

MachineConfig File: It is specific to machine or server. There can be only one MachineConfig File into an application.