ads

Thursday, April 16, 2009

Display All Server Files in Server using C# and ASP.NET

DirectoryInfo di = newDirectoryInfo(Server.MapPath("/"));

FileInfo[] fi = di.GetFiles();

fi = di.GetFiles("*.*");

foreach (FileInfo fi1 in di.GetFiles())

{

Response.Write( fi1.FullName.ToString());

Response.Write("<br />");

}

Wednesday, April 8, 2009

Cross-Page Posting ASP .NET

Make 2 forms name it page1.aspx and page2.aspx

on page1.aspx:

Add a TextBox and Button Control

Go to the Button Control Properties and set the PostbackUrl = "~/page2.aspx"

on Page2.aspx:

Add a Label Control and on the Page_Load Event add this following code.

protectedvoidPage_Load(objectsender, EventArgs e)

{

if (PreviousPage != null)

{

if (PreviousPage.IsCrossPagePostBack == true)

{

Label1.Text = "Cross-page post.";

TextBox tb = (TextBox)PreviousPage.FindControl("TextBox1");

this.Title = tb.Text;

}

}

else

{

Label1.Text = "You are not allowed to access this page!";

}

}

Google Search