19 Jul 2017

17 Jul 2017

How to pass query string in MVC controller

How to pass query string in MVC controller




File => New Project
Templates => Visual C# => ASP.NET MVC Web Application

Right click on Models => Add => Class =>School.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QueryStringsinAsp.netMVC.Models
{
public class School
{
public int ID { get; set; }
public string Name { get; set; }
public int age { get; set; }

public List<School> StudentList = new List<School>();

public List<School> school()
{
StudentList.Add(new School() { ID = 1, Name = "Yapheth", age = 12 });
StudentList.Add(new School() { ID = 2, Name = "John", age = 12 });
StudentList.Add(new School() { ID = 3, Name = "Tom", age = 12 });
StudentList.Add(new School() { ID = 4, Name = "Levi", age = 12 });

return StudentList;
}
}

}
==================================================================================================
Controllers => Add Controller=> HomeController => Add
using QueryStringsinAsp.netMVC.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace QueryStringsinAsp.netMVC.Controllers
{
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
return View();
}

public ActionResult Search( string searchWord)
{
School s = new School();
var model = s.school().Where(x => x.Name.StartsWith(searchWord));
return View(model);
}

}
}
==================================================================================================
Right Click on Controller => Add View => Index => Add

@{
ViewBag.Title = "Index";
}

<h2>Index</h2>
@using (Html.BeginForm("Search", "Home", FormMethod.Get))
{
@Html.TextBox("searchWord", null, new { @class = "form-control" });
<input type="submit" value="Search" class="btn btn-primary"/>
}
=================================================================================================
Right Click on search Controller => Add View =>Template List and model Class set to School => Add
@model IEnumerable<QueryStringsinAsp.netMVC.Models.School>

<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.age)
</th>
<th></th>
</tr>

@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.age)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
@Html.ActionLink("Details", "Details", new { id=item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.ID })
</td>
</tr>
}

</table>
<a href="/Home/index">
<input type="button" class="btn btn-danger" value="Back" />
</a>



Only one instance of a ScriptManager can be added to the page in asp.net C#

Only one instance of a ScriptManager can be added to the page in asp.net C#



Solution :

It says it right there...when you have added the script manager in page as well master page, you have to use only One Script manager.

Master page and current page both contains scriptmanager. Remove extra script managers and there should only be one script manager object on one page and child pages.

We can use one script manager on a single page only. If we want to utilize script manager at master page then use proxy script manager at master page, this will make you to not mention script manager at each page. As per my concern you can use a single script manager on one page not multiple. Within which you can use ur content, update panel etc Ajax tools.

16 Jul 2017

How to do animation with ng-hide & ng-show, not using angular-animate.js?

How to do animation with ng-hide & ng-show, not using angular-animate.js?


@keyframes grow {
0% {
display: none;
opacity: 0;
}
1% {
display: block;
opacity: 0;
transform: scale(0);
}
100% {
opacity: 1;
transform: scale(1);
}
}

12 Jul 2017

Import CheckBox value not changing in react-native.

Import CheckBox value not changing in react-native.

Guest Post

Import CheckBox from 'react-native-checkbox'
and i am using it this way
<CheckBox
label='Show Password'
checked={false}
onChange={(checked) => console.log('i am checked')}/>
Trouble i am having is , i am not been able to change it's value.

Solution :

constructor (props) {
super(props)
this.state = {
value:false
}
}
valueChange(value){
if (this.state.value==true) {
this.setState({
value:false
});
}
else{
this.setState({
value:true
});
}
}

<CheckBox
label='Show Password'
checked={this.state.value}
onChange={(checked) => this.valueChange(checked)}/>

================================================

 state = {
checked: false
}

<CheckBox
label='Show Password'
checked={this.state.checked}
onChange={(checked) => this.setState({ checked }) }/>


Users Please post your solution.

Does react native has a navigation drawer menu, Which is best ?

Does react native has a navigation drawer menu React Native

Guest Post :

React-native-router-flux  or  React-native-navigator

Library for Push Notification in React Native

Library for Push Notification in React Native

React-Native-Push-notification and Onesignal..

Guest Post :

Should I manage push notifications.. which library do you recommend?

Solution :

React Native push notification is the client side library to manage events and record the devicetoken, while we will have to have a backend somewhere (Firebase, one signal, parse server or custom made) where you will get the certificates (IOS) certificates and Apikey for gcm (Android) in addition to saving the devicetoken that react native push notification recovered.

Users Please post your solution.

9 Jul 2017

Retrieving images from SQL Server database without using Path in Asp.net MVC

Retrieving images from SQL Server database without using Path in Asp.net MVC

Guest Post :
I want to retrieve image from the database into asp MVC file.I searched on google everyone has stored relative path in db and they are retrieving that but I want to retrieve the image that is stored in db.I am using razor view engine.

Soluton:
Store your image in binary format and retrieve and deserialize it then. Use that encrypted code on image src with javascript syntax. Your image will be visible.

@{
var base64 = Convert.ToBase64String(item.Photo);
var imgSrc = String.Format("data:image/gif;base64,{0}", base64);
}
<td>
<img src="@imgSrc" /> 
</td>

Users Please post your solution.

7 Jul 2017

XMLHttpRequest cannot load. No 'Access-Control-Allow-Origin' header is present on the requested resource. Console error in Node JS

XMLHttpRequest cannot load. No 'Access-Control-Allow-Origin' header is present on the requested resource. Console error in Node JS

Guest Post :
Console error in Node JS
As nodejs Server is running on 3000 port, how to send data to angular app which is running in 9000 port. Server and client are both in my local machine.


XMLHttpRequest cannot load. No 'Access-Control-Allow-Origin' header is present on the requested resource. 

Solution :

Add Cors to express server because your trying to access the server on a different port than the client it will through a cors error. Install cors and then app.use(cors())

npm install cors -- save
Add this to server.js
const cors = require ('cors');
app.use(cors);

Users Please post your solution.

How to send push notification from asp.net core app to android app?

How to send push notification from asp.net core app to android app?

Guest Post :

How to send push notification from asp.net core app to android app?

Solution :

You need a messaging just like "azure messaging" ,  all you need is just subscription to azure service bus and do some integration with your apps. 

Users Please post your solution.

How to create API authentication header using sha256 and base64 in Asp.Net Core

How to create API authentication header using sha256 and base64 in Asp.Net Core

Guest Post :

How to create API authentication header using sha256 and base64 in Asp.Net Core?

Users Please post your solution.

The name 'model' does not exist in current context Asp.net MVC

The name 'model' does not exist in current context



1. Check your reference system.web.mvc and your webconfig if you reference these namespaces system.web.mvc and system.web.mvc.html

2. Check all packages successfully restored when you build it?

3. Check your class files. Whether reference correctly? also check the namespace and access modifiers of your class.

Users Please post your solution too.

5 Jul 2017

Best architecture to be followed for an Asp.Net MVC web application

Best architecture to be followed for an Asp.Net MVC web application

Guest Post :

I would like to know what is the best architecture to be followed for an Asp.Net MVC web application. Will creating a 3 tier architecture a good choice or it does not matter at all? Is having a business layer good choice or will business layer make the application look complex?

Solution :

Prefer to have a project with the Entity Framework model and "Manager" classes that have static methods to access the database through EF, then have another project that is the MVC web site. Bootstrap with KnockoutJS for the front, so it's talking to WebAPI controllers, which are "exposing" the managers from the business layer as needed. Some people like IoC patterns or dependency injection, your mileage may vary.

Depends on the size and complexity of the project. Domain driven design is suited for dealing with a lot of complexity. Check out the onion and hexagonal architectures. Microservices are something else to think about. I would say that TDD (test-driven development) should be a requirement for ALL non-trivial projects... just my opinion.

TDD is fine as long as people commit to maintain the associated test project. Some people forget that TDD is not a replacement for web site testing, users can find every error you left in. TDD is fine for the back-side code that is interfaced from the web site. Unit/integration testing are for developers. UAT should be left to program managers and stakeholders.

Clean coding, IMHO, is having good naming standards, project structures, proper error handling, and proper isolation/elimination of duplicate code. You can apply these techniques to any language and any coding model.

Users Please post your solution too.

An error occurred while signing SignTool.exe not found - Asp.net MVC

An error occurred while signing SignTool.exe not found - Asp.net MVC

Guest Post :

An error occurred while signing SignTool.exe not found - Asp.net MVC

Solution :

1. Right click on the solution go in properties click on signin tab then disable it and rebuild the solution.

2. You need to fix signtool.exe from the VC Installer by installing the clickonce tools.

Users Please post your solution too.

The development server returned response error code: 500 - React Js

The development server returned response error code: 500

Guest Post :

I am facing "The development server returned response error code: 500" error after installing a package. I tried Uninstall that package, Change port 8081 to 8088, Recreated the project But no use. Please make suggestion how can I get rid of this error?

Users Please post your solution too.

3 Jul 2017

Difference between Angularjs and jQuery ?

Difference between Angularjs and jQuery ?

 jQuery -> Library
Angular -> Framework

jquery is a bit of shortcut in javascript. its more of an extension library that extends core javascript language functionalities. Angular on the other hand is a framework designed to simplify the development process through special methodology.

jQuery is library use for DOM manipulations while on the other hand AngularJS is different beast full fledged Framework modeled on MVC.

jquery is a small piece inside the big box of angularjs..jquery working only small events or functions, but angularjs doing the whole DOM.

AngularJS is a JavaScript frameworks which allows us to develop single page application.Where jQuery is a library used for manipulating DOM.We can use Jquery with all JavaScript frameworks..it makes things simpler than JavaScript code.


Users Please post your answer too.