获取所有表格的名称 [英] get the names of all the forms

查看:82
本文介绍了获取所有表格的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取在ASP.net中的项目中创建的所有Web表单的名称.
请帮忙.在此先感谢.

How to get the names of all the web forms created in a project in ASP.net.
Please Help. Thanks in Advance.

推荐答案

用"Forms"表示"Web Form"(Aspx)吗?
如果是,那么是否要以编程方式获取"Web Form"名称(Aspx页面名称)?

如果是,那么,您应该编写一种方法来递归搜索Web根文件夹,并读取所有Web表单(Aspx页面)名称并返回.
但是,如果我的假设不正确,请进一步说明您的问题.
By "Forms" do you mean "Web Form" (Aspx)?

If yes, then, do you want to get the "Web Form" names (Aspx page names) programmatically?

If yes, then, you should write a method that searches the Web root folder recursively and read all Web form (Aspx pages) names and returns.

However, if my assumptions are not correct, then please clarify your questions with further information.


您也许可以使用反射来做到这一点.但是,鉴于您的表单直到被请求时才存在,因此最好的方法可能是在项目的所有子文件夹中搜索.aspx文件.
You might be able to use reflection to do this. However, given that your forms don''t exist until they are requested, the best way may be to search for .aspx files in all subfolders of your project.


使用Server.Mappath和用于检测应用程序根文件夹的根文件夹名称.
使用System.IO命名空间,您将找到不同的文件和目录处理程序.
递归遍历一个循环,看看是否page.extension ==".aspx"
然后将该数据存储到数组中,
最后,您将拥有所有页面.

谢谢.

不要忘记标记为答案
Hiren Solanki
Use Server.Mappath and name of your root folder to detect root folder of your application.
using System.IO namespace you will find different file and directory handler.
Recursively traverse through a loop and See if page.extension == ".aspx"
then Store that data into array,
and finally you will have all your pages.

Thanks.

Dont forget to mark as a answer
Hiren Solanki


这篇关于获取所有表格的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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