首页 > 编程知识 正文

java反射调用方法,java怎么调用方法

时间:2023-05-05 20:03:49 阅读:246306 作者:1906

【第一种】

在.aspx.cs中写

public partial class UserInfoList : System.Web.UI.Page { public string StrHtml { get; set; } protected void Page_Load(object sender, EventArgs e) { BLL.UserInfoService UserInfoService = new BLL.UserInfoService(); List<UserInfo>list=UserInfoService.GetList(); StringBuilder sb = new StringBuilder(); foreach (UserInfo userInfo in list) { sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td></tr>",userInfo.Id,userInfo.UserName,userInfo.UserPass,userInfo.Email,userInfo.RegTime.ToShortDateString()); } StrHtml = sb.ToString(); } }

在.aspx中写

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserInfoList.aspx.cs" Inherits="CZBK.ItcastProject.WebApp._2015_5_29.UserInfoList" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <script type="text/javascript"> window.onload = function () { }; </script></head><body> <form id="form1" runat="server"> <div> <table> <tr><th>编号</th><th>用户名</th><th>密码</th><th>邮箱</th><th>时间</th><th>删除</th><th>详细</th><th>编辑</th></tr> <%=StrHtml%> </table> </div> </form></body></html> 【第二种】 public partial class UserInfoList : System.Web.UI.Page { public string StrHtml { get; set; } public List<UserInfo> UserList { get; set; } protected void Page_Load(object sender, EventArgs e) { BLL.UserInfoService UserInfoService = new BLL.UserInfoService(); List<UserInfo>list=UserInfoService.GetList(); UserList = list; } } <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserInfoList.aspx.cs" Inherits="CZBK.ItcastProject.WebApp._2015_5_29.UserInfoList" %><!DOCTYPE html><%@ Import Namespace="CZBK.ItcastProject.Model" %><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <script type="text/javascript"> window.onload = function () { }; </script></head><body> <form id="form1" runat="server"> <div> <table> <tr><th>编号</th><th>用户名</th><th>密码</th><th>邮箱</th><th>时间</th><th>删除</th><th>详细</th><th>编辑</th></tr> <% foreach(UserInfo userInfo in UserList){%> <tr> <td><%=userInfo.Id %></td> <td><%=userInfo.UserName %></td> <td><%=userInfo.UserPass %></td> <td><%=userInfo.Email %></td> <td><%=userInfo.RegTime.ToShortDateString() %></td> </tr> <%} %> </table> </div> </form></body></html>

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。