我使用asp.net mvc4和razor开发了一个Web应用程序.在我的应用程序中有一个文件上传控件来上传图像并保存在临时位置.
在保存图像之前,应将图像重新调整为特定大小,然后保存在给定的临时位置.
这是我在控制器类中使用的代码.
public class FileUploadController : Controller
{
//
// GET: /FileUpload/
public ActionResult Index()
{
return View();
}
public ActionResult FileUpload()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult FileUpload(HttpPostedFileBase uploadFile)
{
if (uploadFile.ContentLength > 0)
{
string relativePath = "~/img/" + Path.GetFileName(uploadFile.FileName);
string physicalPath = Server.MapPath(relativePath);
FileUploadModel.ResizeAndSave(relativePath, uploadFile.FileName, uploadFile.InputStream, uploadFile.ContentLength, true);
return View((object)relativePath);
}
return View();
}
}
Run Code Online (Sandbox Code Playgroud)
这是模型类中使用的代码
public class FileUploadModel
{
[Required]
public HttpPostedFileWrapper ImageUploaded { get; set; }
public static void ResizeAndSave(string savePath, string …Run Code Online (Sandbox Code Playgroud) 我使用kendo ui工具开发了一个Web应用程序,还有一个带有批量编辑模式的kendo网格.
但是当我按下删除按钮以获取剑道网格中的任何记录时,它将从网格中的列表中删除但实际上不在数据源中.当我重新加载页面或网格时,删除的项目仍然存在.
这是我网格的代码
<div id="grid">
</div>
<script type="text/javascript">
$("#submitMarketUser").click(function () {
var grid = $("#grid").data("kendoGrid");
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "WholeSaleTrade/GetTradeProductDetail",
dataType: "json",
data: {
test: $("#Names").val()
}
},
destroy: {
url: "WholeSaleTrade/DeletePro",
type: "POST",
dataType: "jsonp",
data: {
DAKy: $("#Names").val(),
DIKy: $("#btntxt").val()
}
},
create: {
url: "WholeSaleTrade/CreateProduct",
type: "POST",
dataType: "jsonp",
data: {
AKy: $("#Names").val(),
IKy: $("#btntxt").val()
}
}
},
pageSize: 5,
schema: {
model: {
id: "ProductKey", …Run Code Online (Sandbox Code Playgroud) 我使用asp.net mvc4和razor语法开发了一个Web应用程序.我需要使用文件上传器上传图像,并在同一页面中显示图像的详细信息.
作为一个例子有一个"file uploader"和"submit button"在"contact page"我的应用程序.当我上传一个人的图像和click提交按钮时,它应该在页面的某个位置显示图像,其中的详细信息如图像名称,大小等.
有没有可能实现这一目标的方法?
这是我的控制器类的代码
public class FileUploadController : Controller
{
//
// GET: /FileUpload/
public ActionResult Index()
{
return View();
}
public ActionResult FileUpload()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult FileUpload(HttpPostedFileBase uploadFile)
{
if (uploadFile.ContentLength > 0)
{
string filePath = Path.Combine(HttpContext.Server.MapPath("~/Img/"),
Path.GetFileName(uploadFile.FileName));
}
return View();
}
}
Run Code Online (Sandbox Code Playgroud)
这是视图的代码
<h2>FileUpload</h2>
@(Html.BeginForm("FileUpload", "FileUpload",FormMethod.Post, new { enctype = "multipart/form-data" }))
<input name="uploadFile" type="file" />
<input type="submit" …Run Code Online (Sandbox Code Playgroud) <button class="k-button" id="batchGrid">
Batch Edit</button>
<div id="example" class="k-content">
<div id="batchgrid">
</div>
</div>
<script>
$("#batchGrid").click(function () {
var crudServiceBaseUrl = "http://demos.kendoui.com/service",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "/Products",
dataType: "jsonp"
},
update: {
url: crudServiceBaseUrl + "/Products/Update",
dataType: "jsonp"
},
destroy: {
url: crudServiceBaseUrl + "/Products/Destroy",
dataType: "jsonp"
},
create: {
url: crudServiceBaseUrl + "/Products/Create",
dataType: "jsonp"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return { models: kendo.stringify(options.models) };
} …Run Code Online (Sandbox Code Playgroud) 我用c#开发了一个Windows窗体应用程序.
它有2种形式,如登录表单和主表单.当我输入正确的登录凭据时,它应该关闭(不隐藏)登录表单并显示主表单.
我使用以下代码
MainForm main=new MainForm();
this.hide();//close login form
main.show();//display main form
Run Code Online (Sandbox Code Playgroud)
但是当我使用mdi容器中的十字标记(右上角)关闭主窗体时,主窗体关闭但应用程序仍在任务管理器中运行.
如果我使用以下代码而不是以前的代码,应用程序将在主窗体显示之前关闭.
this.close()//close login form
main.show();//display main form
Run Code Online (Sandbox Code Playgroud)
我是否必须从主窗体中隐藏mdi容器,或者有任何方法可以实现此目的吗?请帮忙.
我使用mvc4开发了一个Web应用程序.
在这种情况下,我需要使用javascript获取文本框值(实际上是在文本框中输入的文本).
这是我正在使用的代码
@model PortalModels.WholeSaleModelUser
@using (Html.BeginForm("uploadFile", "WholeSaleTrade", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>WholeSaleModelUser</legend>
<table>
<tr>
<td>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
</td>
<td>
<div class="editor-field">
@Html.TextBoxFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
</td>
</tr>
</table>
<div id="partial">
<table>
<tr>
<td>
<img id="blah" src="../../Images/no_image.jpg" alt="your image" height="200px" width="170px" />
</td>
</tr>
</table>
<script type="text/javascript">
function loadUserImage() {
var userImg = document.getElementById("blah");
var imgNm = $("#Name").value;
userImg.src = "D:/FEISPortal/FortalApplication/Img/" + imgNm + ".png";
alert(imgNm);
alert(userImg.src); …Run Code Online (Sandbox Code Playgroud) c# ×3
jquery ×2
kendo-grid ×2
razor ×2
enter ×1
file-upload ×1
image-upload ×1
javascript ×1
kendo-ui ×1
login ×1
mdi ×1
winforms ×1