小编Lor*_*ion的帖子

删除放大器; 来自javascript中的字符串

我将一个预制的URL字符串作为模型传递给我在MVC项目中的视图.

我将URL作为encodedURIComponent传递给我的控制器:

window.location = '@Url.Content("~/Default/UserAgreement?registerData=")' + encodeURIComponent(jsonHttp);
Run Code Online (Sandbox Code Playgroud)

然后我将字符串作为模型传递

   public ActionResult UserAgreement(String registerData)
    {
        return View(null, null, System.Uri.UnescapeDataString(registerData));
    }
Run Code Online (Sandbox Code Playgroud)

然后,当我尝试记录它时,我无法摆脱&这些工作:

var urlString = '@Model'.replace("&", "&");
console.log(urlString);

var urlString = decodeURIComponent('@Model');
console.log(urlString);
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么??

asp.net-mvc jquery razor

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

viewControllers在swift中的indexOfObject

我有这个Objective-c方法,我正在尝试重写swift.

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    int index = [navigationController.viewControllers indexOfObject:viewController];
    self.pageControl.currentPage = index;
}
Run Code Online (Sandbox Code Playgroud)

我在使用swift编写这一行时遇到了困难:

int index = [navigationController.viewControllers indexOfObject:viewController];
Run Code Online (Sandbox Code Playgroud)

我如何访问IndexOfObject?

indexof ios swift

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

如果filepath不存在,则创建serverfolder

我有一个控制器方法来处理来自jquery脚本的文件上传.我使用以下代码指定文件路径Path.Combine(Server.MapPath("~/UserFiles/"), qqfile);我想添加一个指定文件子文件夹的参数,但我只能指定现有文件夹.

如果它不存在,是否有任何简单的方法可以在服务器上创建子文件夹?

这是我的控制器方法:

public ActionResult FileUpload(string qqfile)
{
    var file = string.Empty;

    try
    {
        var stream = Request.InputStream;
        if (String.IsNullOrEmpty(Request["qqfile"]))
        {
            // IE
            HttpPostedFileBase postedFile = Request.Files[0];
            stream = postedFile.InputStream;
            file = Path.Combine(Server.MapPath("~/UserFiles/"), System.IO.Path.GetFileName(Request.Files[0].FileName));
        }
        else
        {
            //Webkit, Mozilla
            file = Path.Combine(Server.MapPath("~/UserFiles/"), qqfile);
        }

        var buffer = new byte[stream.Length];
        stream.Read(buffer, 0, buffer.Length);
        System.IO.File.WriteAllBytes(file, buffer);
    }
    catch (Exception ex)
    {
        return Json(new { success = false, message = ex.Message }, "application/json");
    }

    return Json(new { success = true …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc file

0
推荐指数
1
解决办法
2418
查看次数

C#修改HTML内容

我正在尝试发送带有 HTML 正文的电子邮件,在发送邮件之前我想修改一些 HTML。基本上就像在 jquery 中一样,我需要更改具有某些 ID 的 div 内的一些文本值。

我尝试使用https://github.com/jamietre/CsQuery但我没有找到有关 ID 选择器的任何信息。

有人可以推荐任何其他解决方案吗?

这是我现在的 sendEmail 代码:

public static void sendEmail(String reciverMail, String Subject1, String Body1)
{
    if (reciverMail.Contains('@') && reciverMail != "")
    {
        using (StreamReader reader = File.OpenText(HttpContext.Current.Server.MapPath("~/mail.htm")))
        {

            SmtpClient client = new SmtpClient();
            client.UseDefaultCredentials = false;
            client.Credentials = SmtpServerCredentials;
            client.Host = SmtpServerAddress;
            MailMessage mail = new MailMessage();
            mail.From = new MailAddress(SenderAddress, SenderName1);
            mail.To.Add(reciverMail);
            mail.Subject = Subject1;
            mail.IsBodyHtml = true;
            mail.BodyEncoding = System.Text.Encoding.UTF8;
            //mail.Body = Body1;
            mail.Body …
Run Code Online (Sandbox Code Playgroud)

html c# jquery

0
推荐指数
1
解决办法
1930
查看次数

在javascript中将2小时添加到datetime-string

我从webservice获得以下字符串2014-06-05T10:27:47Z.我想加2小时.

我试图将它转换为日期并添加时间,但它不起作用.代码如下:

var d = new Date("2014-06-05T10:27:47Z");
d = new Date(d + 2*60*60*1000);
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

javascript datetime

0
推荐指数
2
解决办法
114
查看次数

不明白"不包含'GetEnumerator'的公开定义""

我不明白我是如何解决这个问题的.我有两个foreach循环:

foreach (deviceDetailsModel.Detail d in ddm.device.details)
{
    foreach (deviceDetailsModel.Entry e in d)
    {
        //TODO
    }
}
Run Code Online (Sandbox Code Playgroud)

在2日for循环我得到does not contain a public definition for 'GetEnumerator'错误.我究竟做错了什么?

这是班级:

public class deviceDetailsModel
{
    public int totalCount { get; set; }
    public string messages { get; set; }
    public Device device { get; set; }

    public class Entry
    {
        public string key { get; set; }
        public object value { get; set; }
    }

    public class Detail
    {
        public List<Entry> entry …
Run Code Online (Sandbox Code Playgroud)

c# class

0
推荐指数
1
解决办法
1656
查看次数

同步ajax请求未处理同步

我有一个发送多个ajax请求的循环.

完成所有这些后,我想重新加载我的页面.

$.each(uuids, function (i, e) {
    console.log("Sending request for: " + e)
    $.ajax({
        type: 'GET',
        data: {
            _rnd: new Date().getTime()
        },
        url: addToGroupUrl + '?label=' + encodeURIComponent($("#changeGroupSelect").val()) + '&labelDisplay=' + encodeURIComponent($("#changeGroupSelect option:selected").text()) + '&uuid=' + e,
        dataType: 'json',
        async: 'false',
    });
});

location.reload()
Run Code Online (Sandbox Code Playgroud)

现在我遇到了并非所有请求都出现的问题.循环创建所有请求,但是一旦完成location.reload(),服务器就会停止接收请求.

它似乎async: 'false'只是准备请求,但它们被处理为异步.

我怎么想在这里思考?我想在发送所有请求后重新加载我的页面.

javascript ajax jquery

0
推荐指数
1
解决办法
38
查看次数

带有OR和NULL值的SQL WHERE条件

我正在创建一个存储过程,其中所有参数将在WHERE条件中使用.

当我有一个查询时,我知道如何处理空值:

WHERE value1 = val1 AND value2 = val2 AND value3 = val3
Run Code Online (Sandbox Code Playgroud)

处理空值:

WHERE (value1 is null OR value1 = val1) 
AND (value2 is null OR value2 = val2) 
AND (value3 is null OR value3 = val3) 
Run Code Online (Sandbox Code Playgroud)

但是我应该如何使用OR查询?

WHERE value1 = val1 OR value2 = val2 OR value3 = val3
Run Code Online (Sandbox Code Playgroud)

显然这不起作用,因为我将获得所有行

WHERE (value1 is null OR value1 = val1) 
OR (value2 is null OR value2 = val2) 
OR (value3 is null OR value3 = val3) 
Run Code Online (Sandbox Code Playgroud)

我该怎么解决这个问题?

sql t-sql

-2
推荐指数
1
解决办法
70
查看次数

标签 统计

c# ×3

jquery ×3

asp.net-mvc ×2

javascript ×2

ajax ×1

class ×1

datetime ×1

file ×1

html ×1

indexof ×1

ios ×1

razor ×1

sql ×1

swift ×1

t-sql ×1