小编Ali*_*hşi的帖子

ASP.NET MVC Jquery Ajax发布表单序列化?

Ajax功能

$(function () {
    $('form').submit(function () {
        if ($(this).valid()) {
            $.ajax({
                url: this.action,
                type: this.method,
                data: { model: $(this).serialize(), locations: getCheckedLocation(), reports: getCheckedReports() },
                beforeSend: function () {

                },
                complete: function () {

                },
                success: function (result) {
                    $('#user_operations_container').html(result);
                    setTimeout(function () { LoadAction('@Url.Action("GetAllUsers", "User")') }, 1000);
                    $("#widgets ul li a").removeClass("link_active");
                    $("#widgets ul li:first-child a").addClass("link_active");
                }
            });
        }
        return false;
    });
});
Run Code Online (Sandbox Code Playgroud)

在ajax数据属性中使用的函数

function getCheckedLocation() {
    var nodes = $('#tt_location').tree('getChecked');
    var s = '';
    for (var i = 0; i < …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc jquery

11
推荐指数
1
解决办法
3万
查看次数

锚点击并保持页面位置?

在我的页面中有一些没有链接的锚点,如下所示:

<a href="#">Anchor</a>
Run Code Online (Sandbox Code Playgroud)

当我单击页面底部的锚点时,页面将滚动到顶部.如果我点击链接,我想保持页面位置.我怎样才能做到这一点.(没有js对我来说更好)

我希望,我能解释一下.

提前致谢.

html javascript

9
推荐指数
1
解决办法
1万
查看次数

视图如何知道要使用哪种布局?默认在哪里?

在默认的mvc应用程序中.有布局和内容页面,你知道(_Layout,Home,Contact等)

内容页面不包含布局参考,因为:

Layout = "~/Views/Shared/_Layout.cshtml";
Run Code Online (Sandbox Code Playgroud)

在内容页面中,此代码丢失.但他们的工作.没有布局参考,它如何做到这一点?

asp.net-mvc layout razor

8
推荐指数
2
解决办法
4169
查看次数

Linq联盟用法?

SQL:

SELECT date,total_usage_T1 as TotalUsageValue,'T1' as UsageType FROM TblSayacOkumalari
UNION ALL
SELECT date,total_usage_T2 as TotalUsageValue,'T2' as UsageType FROM TblSayacOkumalari
Run Code Online (Sandbox Code Playgroud)

我尝试将其转换为linq

IEnumerable<TblSayacOkumalari> sayac_okumalari = entity.TblSayacOkumalari
.Select(x => new 
    { x.date, x.total_usage_T1 })
.Union(entity.TblSayacOkumalari.Select(x => new 
    { x.date, x.total_usage_T2 }));
Run Code Online (Sandbox Code Playgroud)

但我不知道如何转换'T1' as UsageType为linq.我的工会使用也是不正确的.

我的表字段如下:

| date | total_usage_T1 | total_usage_T2 |

| 2010 |             30 |             40 |
| 2011 |             40 |             45 |
| 2012 |             35 |             50 |
Run Code Online (Sandbox Code Playgroud)

我想要这样

| date | TotalUsageValue | UsageType     | …
Run Code Online (Sandbox Code Playgroud)

c# sql linq sql-to-linq-conversion

8
推荐指数
2
解决办法
4万
查看次数

Linq按日期获取数据组的总和

我的数据看起来像:

 read_date |  T1  |  T2  |
15.02.2000 |   2  |   3  |
16.02.2000 |   4  |   5  |
15.03.2000 |   2  |   3  |
16.03.2000 |   5  |   4  |
Run Code Online (Sandbox Code Playgroud)

我想获得T1和T2的总和,如下所示:

 read_date |  T1  |  T2  |
   02.2000 |   6  |   8  |
   03.2000 |   7  |   7  |   
Run Code Online (Sandbox Code Playgroud)

我尝试写这样的东西:

var result = from s in meter_readings.Take(10)
             group s by new { s.read_date} into g
             select new
             {
                 read_date = g.Key.read_date,
                 T1 = g.Sum(x => x.T1),
                 T2 = g.Sum(x …
Run Code Online (Sandbox Code Playgroud)

c# linq group-by sum

8
推荐指数
2
解决办法
2万
查看次数

Google Combo图表?

在此输入图像描述

我有4个实体,我将它们显示4天.但是第一天和最后几天我看不到其他2个实体.8月3日我看不到T0,T1.8月6日,我看不到T2,T3.

代码

var evalledData = eval("(" + result.chartData + ")");
var ac = new google.visualization.ComboChart($("#chart_div_ay").get(0));

ac.draw(new google.visualization.DataTable(evalledData, 0.5), {
     //title: 'Son 7 günlük sayaç okumalar?n?n toplam?.',
     width: '100%',
     height: 300,
     vAxis: { title: "kW" },
     hAxis: { title: "Gün" },
     seriesType: "bars",
     series: { 5: { type: "line"} }
});
Run Code Online (Sandbox Code Playgroud)

控制器:

public ActionResult MusteriSayaclariOkumalariChartDataTable(DateTime startDate, DateTime endDate, int? musteri_id)
    {
        IEnumerable<TblSayacOkumalari> sayac_okumalari = entity.TblSayacOkumalari;
        var sonuc = from s in sayac_okumalari
                    where s.TblSayaclar.musteri_id == musteri_id && s.okuma_tarihi.Value >= startDate && …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc google-visualization

7
推荐指数
1
解决办法
1504
查看次数

在mvc4中的javascript中访问tempdata

我试图在Javascript中访问TempData.但获得空值.我正在进行ajax调用以更新记录,我想显示Record更新的成功消息.这将来自控制器的UpdateOperation操作.但目前它将显示空值.我也用Firebug查看它显示如下:

function onComplete(e) {

if (e.name == "update") {

alert('');

} 
Run Code Online (Sandbox Code Playgroud)

这是我的控制器代码

 public class OperationController : BaseController
    {
        /// <summary>
        /// Index action will return template view of the page without data
        /// </summary>
        /// <returns>Blank Action</returns>
        public ActionResult Index()
        {
            return this.View();
        }

        /// <summary>
        /// Get all Operation from System
        /// </summary>
        /// <returns>return action result</returns>
        [GridAction]
        public ActionResult SelectOperation()
        {
            IEnumerable<OperationEntity> operationList = OperationComponent.GetAll();
            return this.View(new GridModel(operationList));
        }

        /// <summary>
        /// Method for update operation
        /// </summary> …
Run Code Online (Sandbox Code Playgroud)

javascript asp.net-mvc tempdata asp.net-mvc-4

7
推荐指数
1
解决办法
4万
查看次数

使用EntityFramework设计模式?

接口

public interface IDinnerRepository 
{
    IQueryable<Dinner> FindAllDinners();
    IQueryable<Dinner> FindDinnersByText(string q);

    Dinner GetDinner(int id);

    void Add(Dinner dinner);
    void Delete(Dinner dinner);

    void Save();
}
Run Code Online (Sandbox Code Playgroud)

从上面的接口继承的类

public class DinnerRepository : NerdDinner.Models.IDinnerRepository
{
    NerdDinnerEntities db = new NerdDinnerEntities();

    Public IQueryable<Dinner> FindDinnersByText(string q)
    {
         return db.Dinners.Where(d => d.Title.Contains(q)
             || d.Description.Contains(q)
             || d.HostedBy.Contains(q));
    }

    public IQueryable<Dinner> FindAllDinners()
    {
         return db.Dinners;
    }

    public Dinner GetDinner(int id)
    {
        return db.Dinners.SingleOrDefault(d => d.DinnerID == id);
    }

    public void Add(Dinner dinner)
    {
        db.Dinners.AddObject(dinner);
    }

    public void Delete(Dinner dinner)
    {
        foreach …
Run Code Online (Sandbox Code Playgroud)

c# design-patterns entity-framework

6
推荐指数
2
解决办法
4410
查看次数

DbContext处理?

的DbContext

public class HaberPortalDB : DbContext
{
    public DbSet<Haberler> Haberler { get; set; }
    public DbSet<Kategoriler> Kategoriler { get; set; }
    public DbSet<Yazarlar> Yazarlar { get; set; }
}

public class Haberler
{
    public virtual int Id { get; set; }
    public virtual string Baslik { get; set; }
    public virtual string Aciklama { get; set; }
    public virtual string Icerik { get; set; }

    public virtual int YazarId { get; set; }
    public virtual Yazarlar Yazar { get; set; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc entity-framework idisposable

6
推荐指数
1
解决办法
7308
查看次数

Visual Studio 2017 不记得选项“在解决方案资源管理器中跟踪活动项目”

VS 不记得这个选项是勾选的,当重新启动 IDE 或更改项目分支时。

当我打开 IDE 时,我总是选中这个选项。

我正在使用 VS 17 Enterprise 最新版本。

编辑:我也在使用 resharper(也许它会覆盖 VS 选项)。

visual-studio visual-studio-2017

6
推荐指数
1
解决办法
512
查看次数