我试图将登录名,密码和图片从html5表单发送到asp.net mvc4控制器。我能够在该控制器中获取登录名和密码值。如何获得图片并保存到数据库?
html表格-
<form action="/Home/Index" id="login-form">
<input type="text" name="username">
<input type="password" name="password">
<input type="file" name="photo" accept="image/*;capture=camera">
<button type="submit">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)
jQuery Ajax提交-
var data = $('#login-form').serialize();
var url = $('#login-form').attr('action');
$.post(url, data, function (response) {
//some code here
}
Run Code Online (Sandbox Code Playgroud)
控制器-
[HttpPost]
public JsonResult Index(FormCollection data)
{
String userName = data["username"];
String userPassword = data["password"];
//I want to get that picture here
}
Run Code Online (Sandbox Code Playgroud)
请提出建议。
我正在尝试在我的winapp项目中处理Ctrl + Enter keydown事件.
private void txtAnswer_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode==Keys.Enter && e.KeyCode==Keys.Control)
{
//Some statements.
}
}
Run Code Online (Sandbox Code Playgroud)
但是,它不起作用.有帮助吗?
我正在尝试开发 ASP.NET 5 应用程序。这是一个类,看起来不错(没有红色卷曲下划线)。但是当我尝试构建时,它给出了错误 -SymmetricAlgorithm' does not contain a definition for 'Create'
using System;
using System.IO;
using System.Security.Cryptography;
namespace SalesBook
{
public static class Encryptor
{
private static byte[] EncryptString(string data)
{
byte[] byteData = Common.GetByte(data);
SymmetricAlgorithm algo = SymmetricAlgorithm.Create();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用.net 4.6.1。有什么帮助吗?
我想在 CSS 中为必填字段自动添加星号。
我的标记 -
<label for="DsrCode">DSR Code</label>
<input id="DsrCode" name="DsrCode" required="required" type="text" value="" />
Run Code Online (Sandbox Code Playgroud)
目前我试过 -
input:required label:after {
content: " *";
color: red;
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用。
目前我有以下方法 -
public void CreateWorkbook<T>(List<T> ItemList)
{
PropertyInfo[] properties= typeof(T).GetProperties();
foreach (PropertyInfo prop in properties)
{
}
}
Run Code Online (Sandbox Code Playgroud)
我想T用expando对象替换.但是我无法从expando对象中读取属性.
有什么办法吗?
我的应用程序中有一个类.它必将赢得文本框控件.但是绑定到BookingNo属性的文本框始终显示为零(0).但我希望文本框保持空白.有什么办法吗?这是我的代码片段.
public class Booking
{
private int pBookingNo;
private string pCustomerName;
private string pAddress;
public int BookingNo
{
get { return pBookingNo; }
set
{
if (!value.Equals(pBookingNo))
{
pBookingNo = value;
}
}
}
public string CustomerName
{
get { return pCustomerName; }
set
{
if (!value.Equals(pCustomerName))
{
pCustomerName = value;
}
}
}
public Booking() { }
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
AddDataBindings();
} …Run Code Online (Sandbox Code Playgroud) 我有这样一个基类:
using System.Data;
public class A
{
.....
}
Run Code Online (Sandbox Code Playgroud)
我在B班继承上课.我需要在using System.Data这里再次申报吗?
using System.Data;
public class B: A
{
.....
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我正在尝试将SQL语句编写为字符串文字,其中包含两个变量,如下所示 -
String str="abc"; int val=123;
String sql=@"SELECT Column1, Column2
FROM Table
WHERE Column1= '"" + str + ""' AND Column2 > "" + val + ""
ORDER BY Column1";
Run Code Online (Sandbox Code Playgroud)
但这些变量不被视为变量.有帮助吗?
更新:添加order by子句的屏幕截图.有红色卷曲下划线.

我试图使用图像作为具有模糊效果的响应整页.这是我的css-
body {
padding: 0;
margin: 0;
color: #000;
background-image: url(images/home-page-bg.jpg);
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-color: #464646;
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);
}
Run Code Online (Sandbox Code Playgroud)
但模糊效果不适用于背景图像,而是整个内容变得模糊.
有帮助吗?
您好,我正在尝试从 Windows 窗体应用程序的目录中选择一个文件,但我似乎找不到任何可以从文本框中删除路径并仅保留文件名的内容(例如:“C:\Users\ Users\Documents\File.txt”将只是“File.txt”),它在选择文件时保存输出。
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = @"C:\OUTPUT";
openFileDialog1.Title = "Browse exe Files";
openFileDialog1.CheckFileExists = true;
openFileDialog1.CheckPathExists = true;
openFileDialog1.Filter = "exe files | *.exe";
openFileDialog1.DefaultExt = "exe";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
openFileDialog1.ReadOnlyChecked = true;
openFileDialog1.ShowReadOnly = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox6.Text = openFileDialog1.FileName;
}
Run Code Online (Sandbox Code Playgroud)
谁能启发我如何做到这一点?
谢谢
我知道以下事情
var selectedVal = $('#select option:selected').attr('value');
Run Code Online (Sandbox Code Playgroud)
但是,我想做点什么
var combo=$('#select');
var selectedVal = $(combo + 'option:selected').attr('value');
Run Code Online (Sandbox Code Playgroud)
任何线索?
c# ×6
css ×2
jquery ×2
.net-4.6.1 ×1
asp.net-core ×1
blur ×1
data-binding ×1
dialog ×1
dynamic ×1
html ×1
html5 ×1
inheritance ×1
keydown ×1
path ×1
select ×1
winforms ×1