locked
Create an SQL statement that reflects the documents in your application RRS feed

  • Question

  • User-1694925868 posted

    I have an application with several web pages.  I am developing securities for those web pages.

    Thus, I would like to create a dropdownlist that reflects the various aspx pages, or files inside my application.  I would prefer that it reflected the aspx pages only and avoid the .cs files and config files and etc.  I'm not even sure that this is possible.  Is it?  If so how?  if I can't filter like that I would still take it.

    Thursday, March 24, 2011 3:02 PM

Answers

  • User-2010311731 posted

    ASPX...

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Test</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:DropDownList ID="DropDownList1" runat="server">
            </asp:DropDownList>
        </div>
        </form>
    </body>
    </html>
    

    CS...

    using System;
    using System.IO;
    using System.Web.UI.WebControls;
    
    public partial class Test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath("~/"));
            
            foreach (FileInfo file in dirInfo.GetFiles())
            {
                if (file.Extension == ".aspx")
                {
                    ListItem li = new ListItem();
                    li.Text = file.Name;
                    DropDownList1.Items.Add(li);
                }
            }
        }
    }
    

    Matt

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 24, 2011 4:08 PM