小编cha*_*ara的帖子

Jquery dd/MM/yyyy日期格式验证

我在我的应用程序中使用默认的ASP.NET MVC 4验证包.在视图中,我有一个格式为"dd/MM/yyyy"的日期字段,并且jquery验证无法验证格式.然后我添加了以下代码来覆盖默认行为.

$(function () {
        $.validator.methods.date = function (value, element) {
            Globalize.culture("en-GB");
            // you can alternatively pass the culture to parseDate instead of
            // setting the culture above, like so:
           // parseDate(value, null, "en-AU")
            return this.optional(element) || Globalize.parseDate(value) !== null;
        }
    });
Run Code Online (Sandbox Code Playgroud)

然后解决了日期验证问题,现在我的应用程序不会激活客户端验证,而是服务器端验证.这种行为可能是什么原因?

validation asp.net-mvc jquery date asp.net-mvc-4

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

使用Create Table调用用户定义的函数

我有以下功能

CREATE FUNCTION GetIdentity() RETURNS INT AS
BEGIN
  RETURN (IDENT_CURRENT('tblTempPo'))
END
GO
Run Code Online (Sandbox Code Playgroud)

我需要用create table调用它

create table tblTempPo
(
ID int null,
 BrickVolume AS
              (
              GetIdentity() 
              )
)
Run Code Online (Sandbox Code Playgroud)

我收到了错误

'GetIdentity'不是公认的内置函数名称.

我怎么解决这个问题?

sql sql-server

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

jquery中的简单自定义事件

我正在尝试学习jquery自定义事件.

我需要在页面加载时触发一个简单的事件.

HTML:

<div id="mydiv"> my div</div>
Run Code Online (Sandbox Code Playgroud)

我需要打电话给我自己的事件来发出警报

$("#mydiv").custom();
Run Code Online (Sandbox Code Playgroud)

我尝试了下面的代码.

function customfun()
    {
        $("#mydiv").trigger("custom");
    }

    $(document).ready(function () {

        $("#mydiv").bind(customfun, function () {
            alert('Banana!!!');
        });

    });
Run Code Online (Sandbox Code Playgroud)

javascript jquery

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

Jquery Ajax调用WEB API

我正在尝试对WEB API方法进行简单的jquery ajax调用.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
<script type="text/javascript">

    $(document).ready(function () {

        $.ajax({
            type: 'POST',
            url: 'http://redrock.com:6606/api/values/get',

            dataType: "jsonp",

            crossDomain: true,
            success: function (msg) {

                alert("success");

            },
            error: function (request, status, error) {

                alert(error);
            }
        });
    });

</script>
Run Code Online (Sandbox Code Playgroud)

WEB API动作:

 public IEnumerable<string> Get()
  {
     return new string[] { "value1", "value2" };
  }
Run Code Online (Sandbox Code Playgroud)

ajax调用没有访问WEB API.我在浏览器控制台中收到以下错误.

获取http://redrock.com:6606/api/values/get?callback=jQuery18207315279033500701_1383300951840&_=1383300951850 400(错误请求)

javascript ajax asp.net-mvc jquery asp.net-web-api

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

使用 Jquery 设置 Kendo Grid POPUP 编辑器值

我正在使用具有 POPUP 编辑功能的 Kendo Grid。

在编辑 POPup 时,我有一个如下所示的文本框。

@Html.TextBoxFor(model => model.FirstName, new { style = "width:175px" }) 
Run Code Online (Sandbox Code Playgroud)

然后我使用 Jquery 设置这个文本框值

 $("#FirstName").val("my name");
Run Code Online (Sandbox Code Playgroud)

当我提交弹出窗口以保存值时,它不会将这些值传递给控制器​​。但是,如果我在文本框中键入一个值,则它可以正常工作。

为什么它不能使用通过 Jquery 设置的值?

asp.net-mvc jquery kendo-ui kendo-grid

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

sql IN语句总是为true

我有以下SQL查询

select * from tblArea where AreaDescription in ('Processing1','Geology 66','Site Infrastructure')
Run Code Online (Sandbox Code Playgroud)

目前它显示了AreaDescription中的记录('Processing1','Geology 66','Site Infrastructure')

但我需要将值传递给查询,它将始终为true并显示所有记录.我知道我可以使用where子句

where 1=1
Run Code Online (Sandbox Code Playgroud)

但在这里我需要使用in语句.它可能吗?

sql sql-server

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

在ajax调用中传递参数

我正在尝试对控制器方法进行ajax调用.没有参数它工作正常.一旦我添加参数,我总是会收到一个空参数给cotroller.我想我已经正确地完成了传入ajax调用的参数.

 <script type="text/javascript">
        $(document).ready(function () {
            $('#lstStock').change(function () {
                var serviceURL = '<%= Url.Action("GetStockPrice", "Delivery") %>';
                var dropDownID = $('select[id="lstStock"] option:selected').val();
             alert(dropDownID); // here i get the correct selected ID
                $.ajax({
                    type: "POST",
                    url: serviceURL,
                    data: '{"stockID":"' + dropDownID + '"}',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: successFunc,
                    error: errorFunc
                });

                function successFunc(data, status) {

                    alert(data.Result);


                }

                function errorFunc() {
                    alert('error');
                }
            })
        });
    </script>
Run Code Online (Sandbox Code Playgroud)

控制器:

 [HttpGet]
        public ActionResult GetStockPrice()
        {
            return View();
        }

        [HttpPost]
        [ActionName("GetStockPrice")]
        public ActionResult GetStockPrice1(string stockID)//I …
Run Code Online (Sandbox Code Playgroud)

asp.net ajax asp.net-mvc jquery asp.net-mvc-2

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

Kendo Grid外键列动态绑定

@(Html.Kendo().Grid((IEnumerable<Doc.Web.Models.Common.ContactModel>)Model.contact_lst)  
    .Name("grid")
    .Columns(columns =>
    {

        columns.Bound(o => o.ContactID).Visible(false);
        columns.Bound(o => o.ContactName).Title("Contact Name");
        columns.ForeignKey(p => p.CPOID, (System.Collections.IEnumerable)ViewData["CPOs"], "cpo_id", "contract_po")
                .Title("Company - Contact/Purchase Order");
        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(182);
    })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .Pageable()
    .Sortable()
    .Filterable()
    .ToolBar(toolbar =>
    {
        toolbar.Template(@<text>
           <div class="toolbar">
               <a href="/Contact/EditingInline_Read?grid-mode=insert" class="k-button k-button-icontext k-grid-add">
    <span class="k-icon k-add"></span>Add New Record
</a>
                    <label class="category-label" for="category">Site:</label>
                       @(Html.Kendo().DropDownListFor(m => m.SiteID)
                            .Name("SiteID")
                            .DataTextField("Text")
                            .DataValueField("Value")
                            .Events(e => e.Change("categoriesChange"))
                            .Value(Model.SiteID.ToString())
                            .DataSource(ds =>
                            {
                                ds.Read("ToolbarTemplate_Categories", "Contact");
                            })
                        ) 

                        </div>

        </text>);
    })
    .DataSource(dataSource => …
Run Code Online (Sandbox Code Playgroud)

telerik kendo-ui kendo-grid

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

部分视图中的模型为空

我正在尝试在布局页面中添加局部视图.

模型

public class SummaryPanelModel
    {
        public int TotalDesignDocs { get; set; }
        public int TotalVendorDocs { get; set; }
        public int TotalBusinessDocs { get; set; }
        public int TotalManagementDocs { get; set; }
    }
Run Code Online (Sandbox Code Playgroud)

SummaryPanel_Partial局部视图控制器:

 public ActionResult SummaryPanel_Partial()
        {
            rep = new SummaryRepository();
            SummaryPanelModel model = new SummaryPanelModel();
            model = rep.ReadsummaryPanel();//read from database
            return View(model);
        }
Run Code Online (Sandbox Code Playgroud)

布局页面

<!DOCTYPE html>
<html lang="en">
@{
    Layout = null;
}

 @Html.Partial("SummaryPanel_Partial")
Run Code Online (Sandbox Code Playgroud)

SummaryPanel_Partial局部视图:

@model Doc.Web.Models.SummaryPanel.SummaryPanelModel

<div id="pnlBar">
    @Html.Label(Model.TotalDesignDocs.ToString())
<div/>
Run Code Online (Sandbox Code Playgroud)

尽管我已经在控制器动作中传递了模型,但模型在局部视图中始终为null.

asp.net-mvc razor asp.net-mvc-4

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

从 Web API Core 下载文件 - Angular 7

我正在尝试从服务器下载文件,但该文件并未显示其原始内容,而是显示 [object Object]。

WEB API 核心

[Authorize(AuthenticationSchemes = "Bearer")]
[HttpGet]
public HttpResponseMessage DownloadContractFile(string fileName)
{
    string contentRootPath = _hostingEnvironment.ContentRootPath;
    var folderName = Path.Combine(contentRootPath, FileHandler.ContractFilePath, Convert.ToInt32(User.Identity.Name).ToString());

    var path = Path.Combine(folderName, fileName);

    var memory = new MemoryStream();

    HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
    using (var stream = new FileStream(path, FileMode.Open))
    {
        result.Content = new StreamContent(stream);
        result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
        result.Content.Headers.ContentDisposition.FileName = Path.GetFileName(path);
        result.Content.Headers.ContentType = new MediaTypeHeaderValue(FileHandler.GetContentType(path)); // Text file
        result.Content.Headers.ContentLength = stream.Length;

        return result;
    }
}
Run Code Online (Sandbox Code Playgroud)

Angular 代码:服务方法

  downloadContractFile(fileName: string) {

    const obj: …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-web-api asp.net-core asp.net-core-webapi angular7

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