You are here, seeking some information and we are more than happy to re-direct you to http://webproject.scottgu.com, a right place to start learning how to develop a website using Visual Studio IDE. Though the posts with scottgu.com mostly deal with VS 2005, almost everything they mentioned with their lessons are still applicable to the latest VS releases.
So give it a try, and you will be more than glad to visit one of the best beginners place.
We tease each other calling “Google Programmers” occasionally as we just cut and paste code from forums/websites and meet new business requirements and deadlines.
We started revamping our intranet site recently and was frantically looking at a prospective of converting few .asp driven details using .net application(s)
Our primary requirement was to list the content of a folder, along with subdirectories and files (mostly .pdf and .doc/.docx/.xls/.xlsx)
After loads of googling we came across two potential solutions and they were
The first solution was “too” professional approach for guys like us, who hardly have anything more than few hours of experiences with .net programming
The second solution looked more appropriate as we were looking at something which could be easily altered and adopted to our particular requirement.
Hence we copied the scripts available with the link and started altering them, and with our “extreme” level of exposure to the technology, almost after 72 hours we were able to shape up something which fits into our requirements, somehow and we are sharing the same with you.
We know, it could be done much easier or in a simpler manner, well that part we are leaving for the seasoned .net developers.
First create a .aspx file with name “Default” (eg:Default.aspx) and copy the following code inside the file (Notepad++)
<%–ADD A GRIDVIEW WITH FEW COLUMNS–%>
<asp:GridView ID="GridView2" CssClass="grid" GridLines="None" ShowFooter="true"
AllowPaging="true" PageSize="5" AutoGenerateColumns="false"
runat="server">
<%–A LABEL SHOWING NUMBER OF FILES FOUND IN THE FOLDER.–%>
<p><asp:Label Text="" ID="lblMsg" runat="server"></asp:Label></p>
</div>
</form>
</body>
</html>
[/sourcecode]
Now create another file “Default.aspx.cs” and copy the below code inside the file
[sourcecode language=”csharp”]
using System;
using System.IO;
using System.Globalization;
public partial class _Default : System.Web.UI.Page
{
protected void btShowFiles_Click(object sender, EventArgs e)
{
// ViewState["FileType"] = drop1.SelectedValue; // GET THE FILE TYPE.
GetFilesFromFolder();
}
if (listfiles.Length > 0)
{
// BIND THE LIST OF FILES (IF ANY) WITH GRIDVIEW.
GridView1.Visible = true;
GridView1.DataSource = listfiles;
GridView1.DataBind();
Now move both the files to your web application folder. We were using the default “C:\inetpub\wwwroot” for the testing, hence moved the files to there.
Now you can start calling the application like following
Where memos is an actually folder available within “C:\inetpub\wwwroot” path
If you have folders within the “memos” folder, the application will present you view like following
Based on whether you have subfolders within the “memos” folder the application will either display or hide the Folder(s) grid, the same applies to Files grid as well
The best part is, this application can drill down into any level of nested folders and populate folder and file lists as URLs.
We thank A2S from forums.asp.net for helping us to strip out the extensions from filenames. Please refer to the below link for more details.