问题列表 - 第47756页

MVC:如何将文件上载和其他表单字段发布到一个操作

我正在创建一个文档库应用程序DocumentController,需要上传库中每个doument的缩略图.我想将"文件上载"字段保留在与其他字段(Title,Description,CategoryId等)相同的"创建/编辑"表单中.
问题是我不确定我是否可以混合或嵌套表单标签

Html.BeginForm("Create", "Document", FormMethod.Post, enctype = "multipart/form-data")
Run Code Online (Sandbox Code Playgroud)

Html.BeginForm()
Run Code Online (Sandbox Code Playgroud)

我的观点如下:

 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Publications.WebUI.Models.DocumentEditViewModel >" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Edit
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <fieldset>
        <legend>Edit
            <%=  Html.Truncate(Model.Document.Title, 50)%></legend>
        <%= Html.ValidationSummary(false) %>
        <% using (Html.BeginForm())
           { %>
        <div class="editor-label">
            <%= Html.LabelFor(model => model.Document.Title) %>
        </div>
        <div class="editor-field">
            <%= Html.HiddenFor(model => model.Document.DocumentId ) %>
            <%= Html.ValidationMessageFor(model => model.Document.Title) %>
            <%= Html.TextBoxFor(model => model.Document.Title)%>
        </div>
        <div class="editor-label">
            <%= Html.LabelFor(model => model.Document.DocumentUrl)%>
        </div>
        <div class="editor-field">
            <%= …
Run Code Online (Sandbox Code Playgroud)

forms asp.net-mvc file-upload asp.net-mvc-2

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

方法定义期间返回类型中需要的模板参数

有谁知道为什么返回类型需要模板参数,而在定义模板方法时不需要参数类型?一个例子:

template<typename T>
struct Car {
  Car drive(Car);  // will be defined after the template declaration.
};

// Attempt #1: does not compile.
// Error: use of class template Car requires template arguments
template<typename T>
inline Car Car<T>::drive(Car) {}

// Attempt #2: compiles!  
// The only difference is the use of template argument in return type.
// However, note that the argument to func does not require template argument!
template<typename T>
inline Car<T> Car<T>::drive(Car) {}
Run Code Online (Sandbox Code Playgroud)

不确定为什么返回类型需要模板参数,但参数类型不需要.当尝试#1失败时,我期待尝试#2也失败并且预计我需要:

template<typename T>
inline Car<T> …
Run Code Online (Sandbox Code Playgroud)

c++ templates

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

Android:每个应用程序的电池使用情况

无论如何,是否可以在 API、adb shell、...中获取每个应用程序每秒的电池使用信息?

sdk android power-management

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

Rails 3:多个has_one关联和种子

我正在使用Rails似乎没有做到的数据概念 - 一条路线有两个(也就是两个)机场.我终于想出了如何对我的外键进行硬编码以使它们变得合情合理.

models/route.rb很简单:

class Route < ActiveRecord::Base
  has_one :airport, :foreign_key => 'from_airport_id', :class_name => 'Airport'
  has_one :airport, :foreign_key => 'to_airport_id', :class_name => 'Airport'
end
Run Code Online (Sandbox Code Playgroud)

这一切似乎工作正常,但我似乎无法正确播种.

seeds.rb看起来像这样:

Airport.delete_all
@kpdx = Airport.create(:icao => 'KPDX', :name => 'Portland International Airport', :lat => '45.58869934', :lon => '-122.5979996')
@ksea = Airport.create(:icao => 'KSEA', :name => 'Seattle Tacoma International Airport', :lat => '47.4490013122559', :lon => '-122.30899810791')
Route.delete_all
Route.create(:from_airport_id => @kpdx, :to_airport_id => @ksea, :route => "RIVR6 BTG OLM6")
Route.create(:from_airport_id => @kpdx, …
Run Code Online (Sandbox Code Playgroud)

seed associations ruby-on-rails-3

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

如何在PHP中删除尾随零

嗨,任何人都可以给我一个解释(也许是一个例子),我将如何使用PHP从数字中删除尾随的零.

例如:

"Lat":"37.422005000000000000000000000000","Lon":"-122.84095000000000000000000000000"
Run Code Online (Sandbox Code Playgroud)

将转入:

"Lat":"37.422005","Lon":"-122.84095"
Run Code Online (Sandbox Code Playgroud)

我试图剥离零,使其更具可读性.我尝试使用str_replace()但是这也取代了数字中的零(doh).

谢谢= D

php string

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

如何配置maven shade插件以在我的jar中包含测试代码?

我使用shade maven插件来构建我的项目,以便它的所有依赖项都包含在一个jar中(这使得在Hadoop上运行它更容易).默认情况下,Shade似乎排除了我的测试代码,这是可以理解的.由于我想对我的集群运行集成测试,我希望设置另一个配置文件来为此目的构建一个单独的jar.有没有办法配置这个插件还包括测试代码?

java hadoop maven maven-shade-plugin

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

每个连接的JDBC Statement/PreparedStatement

我想知道每个连接可以同时打开多少语句或预备语句.我真的不明白如果执行多个语句并检索多个结果集,它将如何工作.资源链接与详细信息将有所帮助.

谢谢

java jdbc

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

HTTPS和数据完整性

我还没有对HTTPS做过很多研究,所以我对此有疑问.

是使用HTTPS保护数据完整性还是仅保密?例如,在文件上传时,HTTPS是否保证没有人可以在上传时更改数据,或者只保证没有人可以读取它?

https integrity

7
推荐指数
2
解决办法
5632
查看次数

CSS3 nth-child无法使用Chrome 9

嘿所有,我有这个代码:

    <div class="sidebox">

            <h3>Course Summary</h3>

            <div class="block">

                <h4>Course ID</h4> 
                <p>MS00000001</p>
                <h4>Start Date</h4> 
                <p>14<sup>th</sup> September 2011</p>
                <h4>End Date</h4> 
                <p>12<sup>th</sup> June 2012</p>
                <h4>Cost</h4> 
                <p>£1500.95</p>     

            </div>

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

现在我试图改变每个第二个P标签的颜色

.sidebox .block p:nth-child(odd) {
    color: red !important;
}
Run Code Online (Sandbox Code Playgroud)

我尝试使用它,但它没有工作:/什么都没有改变颜色,我在这里做错了什么?

css google-chrome css-selectors css3

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

如何在c#中创建动态大小的数组或重新调整数组大小?

我需要知道如何在C#中动态调整数组大小.在下面我写的方法中,我需要能够返回一个只包含用户输入的数字的数组,最多包含8个数字.因此,如果用户决定他们只想输入3个数字,则该数组应该只包含3个数字,而不是8个.

现在我知道数组在实例化时需要包含一个大小.那么如何在不使用列表的情况下解决这个问题呢?循环完成后有没有办法重新调整数组的大小?

提前致谢.

        static int[] fillArray()
    {
        int[] myArray;
        myArray = new int[8];
        int count = 0;
        do
        {
            Console.Write("Please enter a number to add to the array or \"x\" to stop: ");
            string consoleInput = Console.ReadLine();
            if (consoleInput == "x")
            {
                Array.Resize(ref myArray, count);
                return myArray;
            }
            else
            {
                myArray[count] = Convert.ToInt32(consoleInput);
                ++count;
            }

        } while (count < 8);

        Array.Resize(ref myArray, count);
        return myArray;

    }
Run Code Online (Sandbox Code Playgroud)

c# arrays

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