[代码]ASP MVC Framework视图显示控制器返回结果

baacloud免费翻墙vpn注册使用

Controller控制器代码,用于返回List 的结果List给View视图显示用

public void FlashGet(String browserAddr)
{
//创建models
FlashGet flashGet = new FlashGet();
//根据url是否为空判断定向到页面
ViewData["test"] = "url is:"+browserAddr;
if (browserAddr==null)
{
RenderView("HowTo");
}
else
{
List<String> Result=flashGet.GetSWFS(browserAddr);
//返回结果给list
ViewData["list"] = Result;
RenderView("SWFList");
}
}

View视图代码,遍历List 的ViewData数据

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="SWFList.aspx.cs" Inherits="FlashSaver.Views.Home.SWFList" %>
<%@ Register TagPrefix="m" Namespace="FlashSaver.App_Code" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
<%=ViewData&#91;"test"&#93;%>
<%
foreach (String path in (ViewData&#91;"list"&#93; as List<String>))
{
Response.Write(path+"<br/>");
}
%>
</asp:Content>
赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏