Skip to content

Instantly share code, notes, and snippets.

@page "{id:int}"
@model EditPageModel
@{
}
<h2>Edit</h2>
<form method="post">
<table class="table table-bordered" style="width:500px">
<tbody>
<tr>
<td>
@page
@*Adding the reference of model class*@
@using NetCoreRazorPageApp.Model
@using Microsoft.EntityFrameworkCore;
@{
ViewData["Title"] = "Home page";
}
@inject NetCoreRazorPageApp.Model.EmployeeDbContext dbcontext
@functions {
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<EmployeeDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("EmployeeDbContext")));
services.AddMvc();
}
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
},
"ConnectionStrings": {
"EmployeeDbContext": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=C:\\LEARNING\\BLOG\\NETCORERAZORPAGEAPP\\NETCORERAZORPAGEAPP\\APPDATA\\EMPLOYEEDB.MDF;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
}
public class EmployeeDbContext : DbContext
{
public EmployeeDbContext(DbContextOptions<EmployeeDbContext> options) : base(options)
{
}
public DbSet<Employee> Employee { get; set; }
}
public class Employee
{
[Key]
public int EmployeeID { get; set; }
[Required]
public string EmployeeName { get; set; }
[Required]
public string EmployeeAddress { get; set; }
}
function SampleCode(){alert(3)}
function SampleCode()
{
var i = 1;
var j = 2;
alert(i + j);
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> SearchCustomer(string prefixText, int count)
{
string conString = ConfigurationManager.ConnectionStrings["AdventureWorksConnectionString"].ConnectionString;
using (SqlConnection conn = new SqlConnection(conString))
{
using (SqlCommand cmd = new SqlCommand())
{
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<script>
function hideOptionList() {
$find('ACE').hidePopup();
}
var finalresult;
//Customize the SetText function to create comma separated string from selected values
Sys.Extended.UI.AutoCompleteBehavior.prototype._setText = function (item) {
var text = (item && item.firstChild) ? item.firstChild.nodeValue : null;
this._timer.set_enabled(false);