MVC 5:如何在按钮单击后从部分视图中获取字段的值 [英] MVC 5: How do I get value from fields from partial view after button click

查看:55
本文介绍了MVC 5:如何在按钮单击后从部分视图中获取字段的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,


$ b $bIám使用VS2015 Pro。创建MVC项目。我有一个视图有几个局部视图。 Partialview(A)包含输入字段;所有字段都包含值。 PartailView(B)包含一个按钮和几个用于显示结果的字段。当我按下按钮时,(A)的填充字段用于多次计算,结果显示在(B)中。但在我进行计算之前,我需要知道PartialView(A)中字段的值。问题:,如何发现部分视图(A)的字段值。我使用了几种技术,但总是得到结果null。



任何帮助都会受到赞赏。

感谢荷兰Peter Bellen

Greetings,

Iám using VS2015 Pro. Creating a MVC project. I have one view with several partial views. Partialview (A) contains input fields; all fields contain values. PartailView (B) contains a button and several fields for displaying results. When I press the button, The filled fields of (A) are being used for several calculations and the results are being displayed in (B). But before I can do the calculations I need to know the values of the fields in PartialView (A). Question:, How can I discover what the values are of the fields of Partialview (A). I used several techniques but Always get the result null.

Any help would be appreciated.
Thanks Peter Bellen, The Netherlands

推荐答案

您好,



您的问题是您需要确保从PartialView(A)发布哪些输入值。



场景:

1.你有3个字段,(InptA,InptB,InptC)

2首先创建一个具有以上属性名称的类(类名:ParVewA)

3.现在创建另一个类(将成为该视图的主要模型),使用PartialA设置属性名称,其类型为ParVewA

4.现在在你的局部视图的HTML中放置字段名称如(PartialA.InptA,PartialA.InptB,PartialA.InptC)



现在当您将数据发布到服务器时,您的模型的属性PartialA将使用部分视图(A)提交的值进行设置
Hi,

Your question is you need to ensure that which input values are posted from PartialView (A).

Scenario :
1. You have 3 fields, (InptA, InptB, InptC)
2. First create a class with above property name ( class Name : ParVewA)
3. Now create another class ( which will be the main model for that view), set a property name with PartialA which typeof ParVewA
4. now in your partial view's HTML put fields name like ( PartialA.InptA,PartialA.InptB, PartialA.InptC)

Now when you post data to server your model's property PartialA would set with the values which has been submitted by Partial View (A)


这篇关于MVC 5:如何在按钮单击后从部分视图中获取字段的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆