小编HaB*_*aBo的帖子

MVC Telerik Grid条件列值?

如何在MVC Telerik Grid Control中完成这项工作

 columns.Template(e => 
            { 
                        if (e.EndDate>DateTime.Now ) 
                        {
                         @Html.ActionLink("Stop", "StopMedication", "Medication", 
                             new { id = e.PrescriptionID }, new { @class = "standard button" })
                        } 
                        else {
                            @Html.ActionLink("Renew", "RenewMedication", "Medication",
                                new { id = e.PrescriptionID }, new { @class = "standard button" })
                             }
          });
Run Code Online (Sandbox Code Playgroud)

grid conditional telerik

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

jQuery如果myform.valid()为true则触发另一个jQuery函数?

我有一个jQuery函数,我想只在表单验证为真时执行
我有验证和其他jQuery工作正常.
问题是现在验证和其他功能都在同一时间执行.
我想仅在表单验证为真时才运行其他函数.这是我的剧本

<script>
            $(document).ready(function () {
                $.validator.addClassRules({
                    fileName: {
                        required: true
                    }
                });
                $("#myform").validate();
                if ($("#myform").valid()) {
                    $(function () {
                        $('#myform').submit(function () {
                            var cboxes = ($('input:checkbox:checked').filter(":checked").length);
                            var nboxes = ($(":checkbox:not(:checked)").length);
                            if ((cboxes > 0) && (nboxes > 0)) {
                                confirm('You have Checked only few locations among the List. \n Are you sure, you do not want to Prescribe from the other locations? ');
                            } else if (cboxes == 0) {
                                alert('Please select atleast One Address \n Where …
Run Code Online (Sandbox Code Playgroud)

validation jquery

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

表单提交无法在Chrome中使用?

我在Chrome中发现了一个奇怪的行为.
我有表格来编辑记录详细信息.

当用户单击Records Grid列表中的Edit时.我的页面加载一个Form,其中包含表单中加载的记录的所有详细信息.这是有趣的问题.如果我不编辑表单中的任何字段,只需单击提交按钮.一切正常.

但是,如果我编辑任何输入字段,然后单击提交.

然后chrome没有提交表单.

它在IE中运行得非常好

我尝试更改提交按钮

<input type="submit" value="Continue" name="submit" class="standard button" id="ContinueButton" onclick="isValidDate()">
Run Code Online (Sandbox Code Playgroud)

<input type="submit" value="Continue" name="submit" class="standard button" >
Run Code Online (Sandbox Code Playgroud)

但没有用

进一步观察.


我注意到.我有不同的文本区域,文本框,日期提交.我可以更改任何文件并提交表格没有问题.但是,如果我更改数量字段并提交然后它将无法正常工作.

google-chrome form-submit

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

带有标识的SQLBulkCopy在目标表中插入

我试图用SQLBulkCopy向SQL Server插入一个通用列表,

我在Identity Field遇到麻烦

我想要我的目标表来生成标识字段我应该如何处理这个,这是我的代码

using (var bulkCopy = new SqlBulkCopy(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
                {
                    bulkCopy.BatchSize = (int)DetailLines;
                    bulkCopy.DestinationTableName = "dbo.tMyTable";

                    var table = new DataTable();
                    var props = TypeDescriptor.GetProperties(typeof(tBFFormularyStatusList))
                        //Dirty hack to make sure we only have system data types 
                        //i.e. filter out the relationships/collections
                                               .Cast<PropertyDescriptor>()
                                               .Where(propertyInfo => propertyInfo.PropertyType.Namespace.Equals("System"))
                                               .ToArray();
                    foreach (var propertyInfo in props)
                    {
                        bulkCopy.ColumnMappings.Add(propertyInfo.Name, propertyInfo.Name);
                        table.Columns.Add(propertyInfo.Name, Nullable.GetUnderlyingType(propertyInfo.PropertyType) ?? propertyInfo.PropertyType);
                    }

                    var values = new object[props.Length];
                    foreach (var item in myGenericList)
                    {
                        for (var i = 0; i < values.Length; …
Run Code Online (Sandbox Code Playgroud)

sqlbulkcopy sql-server-2008 c#-4.0

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

防止在IIS 7.5上将父web.config继承给子应用程序

IIS 7.5上,我具有使用parentAppPool的父站点和使用childAppPool的SubApplication

父站点加载一切正常,但是当我以http://parentSite.com/SubApplication访问subApplication时,它期望从父站点bin中获得DLL。

为了防止在web.config继承,我想包装<system.web><location path="SubApplication" inheritInChildApplications="false"><location path="." inheritInChildApplications="false">这打破了父网站的工作。

然后我尝试将enableConfigurationOverride="false"属性添加 到SubApplicationPoolapplicationHost.config也没有用

任何帮助,将不胜感激。

web.config的高级框架 在此处输入图片说明

尝试此操作时,我在父站点上收到Telerik错误,但子站点有效!

web.config中缺少“〜/ Telerik.Web.UI.WebResource.axd”。RadScriptManager要求在web.config中注册HttpHandler。请使用控件智能标记自动添加处理程序,或查看帮助以获取更多信息:控件> RadScriptManager

asp.net iis inheritance web-config

5
推荐指数
1
解决办法
4837
查看次数

如何按页码访问OpenXML内容?

使用OpenXML,我可以按页码阅读文档内容吗?

wordDocument.MainDocumentPart.Document.Body 给出完整文档的内容.

  public void OpenWordprocessingDocumentReadonly()
        {
            string filepath = @"C:\...\test.docx";
            // Open a WordprocessingDocument based on a filepath.
            using (WordprocessingDocument wordDocument =
                WordprocessingDocument.Open(filepath, false))
            {
                // Assign a reference to the existing document body.  
                Body body = wordDocument.MainDocumentPart.Document.Body;
                int pageCount = 0;
                if (wordDocument.ExtendedFilePropertiesPart.Properties.Pages.Text != null)
                {
                    pageCount = Convert.ToInt32(wordDocument.ExtendedFilePropertiesPart.Properties.Pages.Text);
                }
                for (int i = 1; i <= pageCount; i++)
                {
                    //Read the content by page number
                }
            }
        }
Run Code Online (Sandbox Code Playgroud)

MSDN 参考


更新1:

它看起来像分页符设置如下

<w:p w:rsidR="003328B0" w:rsidRDefault="003328B0">
        <w:r>
            <w:br …
Run Code Online (Sandbox Code Playgroud)

c# xml openxml openxml-sdk

5
推荐指数
2
解决办法
3359
查看次数

使用 C# MongoDB 查询在数据库集合中查找最近的纬度/经度

我有一个 MongoDB 集合,其中包含数百万条记录,如下所示

{ 
    "_id" : ObjectId("5e662d6e9ce8bf144c715afd"), 
    "X" : 19.229000091552734, 
    "Y" : 233.723388671875,  
    "Data" : {
       // Some data
    }
}
{ 
    "_id" : ObjectId("5e662d6e9ce8bf144c715afe"), 
    "X" : 19.229000091552734, 
    "Y" : 2773.426513671875, 
    "Data" : {
        // Some data
    }
}
Run Code Online (Sandbox Code Playgroud)

我想出了两个地理坐标的远程计算器

public static double DistanceTo(this Coordinates baseCoordinates, Coordinates targetCoordinates, UnitOfLength unitOfLength)
        {
            var baseRad = Math.PI * baseCoordinates.Latitude / 180;
            var targetRad = Math.PI * targetCoordinates.Latitude / 180;
            var theta = baseCoordinates.Longitude - targetCoordinates.Longitude;
            var thetaRad = Math.PI * theta / …
Run Code Online (Sandbox Code Playgroud)

c# mongodb mongodb-csharp-2.0

5
推荐指数
0
解决办法
556
查看次数

使用jQuery函数的Telerik MVC网格刷新

嗨,我有两个MVC Telerik网格在一个视图中出现.

每个网格都有一个带有编辑链接的自定义列

当用户单击编辑链接时,对话框模型将弹出一个表单,并在用户点击保存按钮后.脚本下面会运行

 function OpenStopForm() {

    $("#dialog:ui-dialog").dialog("destroy");
    $("#dialog-model").dialog({
        height: 220,
        width: 340,
        modal: true,
        buttons: {
            "Save": function () {
                var note = $('textarea[name=StopNote]').val();
                $.ajax({
                    type: "POST",
                    url: "/Medication/StopMedication",
                    data: { ID: pid, StopNote: note },
                    dataType: "json",
                    success: refreshGrid()
                });
                $(this).dialog("close");
            },
            Cancel: function () {
                $(this).dialog("close");
            }
        }
    });

}
Run Code Online (Sandbox Code Playgroud)

在上面的函数成功运行之后,
我希望两个telerik网格能够通过某种ajax调用进行刷新.
我虽然调用了这样的功能
:refreshGrid

function refreshGrid() {
     $('#CurrentMedication').data('t-grid').ajaxRequest();
}
Run Code Online (Sandbox Code Playgroud)

但是在执行Controller操作之前调用了refreshGrid函数.
我希望在控制器操作完成后调用此函数.

我不确定我的语法是否正确!

我试着从这里做点什么

任何人都可以帮助我在ajax Post上成功调用refreshgrid函数.另外请用我的功能来更正网格.

model-view-controller grid jquery refresh telerik

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

MongoDB 将字符串类型转换为浮点类型

按照这里的建议MongoDB: How to change the type of a field? 我尝试更新我的集合以更改字段的类型及其值。

这是更新查询

db.MyCollection.find({"ProjectID" : 44, "Cost": {$exists: true}}).forEach(function(doc){
    if(doc.Cost.length > 0){
        var newCost = doc.Cost.replace(/,/g, '').replace(/\$/g, '');
        doc.Cost =  parseFloat(newCost).toFixed(2);  
        db.MyCollection.save(doc);
        } // End of If Condition
    }) // End of foreach
Run Code Online (Sandbox Code Playgroud)

完成上述查询后,当我运行以下命令时

db.MyCollection.find({"ProjectID" : 44},{Cost:1})
Run Code Online (Sandbox Code Playgroud)

我仍然有Cost字段作为字符串。

{
    "_id" : ObjectId("576919b66bab3bfcb9ff0915"),
    "Cost" : "11531.23"
}

/* 7 */
{
    "_id" : ObjectId("576919b66bab3bfcb9ff0916"),
    "Cost" : "13900.64"
}

/* 8 */
{
    "_id" : ObjectId("576919b66bab3bfcb9ff0917"),
    "Cost" : "15000.86"
}
Run Code Online (Sandbox Code Playgroud)

我在这里做错了什么? …

mongodb mongo-shell

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

从.NET Core/ASP.NET Core中的类库访问App密钥数据

要访问类库中的App Keys,我们是否需要在每个需要访问AppKey的类库和类中执行以下代码?

public static IConfigurationRoot Configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
Run Code Online (Sandbox Code Playgroud)

这是我在Microsoft文档中发现的,但这看起来非常多余.

项目中的启动类如下所示

 public class Startup
    {
        public IConfigurationRoot Configuration { get; set; }

        public Startup()
        {
            var builder = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json");

            Configuration = builder.Build();
        }

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddEntityFramework().AddEntityFrameworkSqlServer()
                .AddDbContext<DbContext>(options =>
                    options.UseSqlServer(Configuration["Data:MyDb:ConnectionString"]));
        }
    }
Run Code Online (Sandbox Code Playgroud)

那么我应该如何在项目的每个类中注入这个" IConfigurationRoot ".我是否必须在每个类库中重复此Startup类?为什么这不是.NET Core Framework的一部分?

c# asp.net .net-core asp.net-core

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