+ Reply to Thread
Results 1 to 7 of 7

Thread: c# dynamic html on runtime.

  1. #1
    Newbie tikejhya is an unknown quantity at this point
    Join Date
    Aug 2009
    Posts
    3

    c# dynamic html on runtime.

    hi One and all,

    I am trying to build web server for win Mo and i am trying to get the link of folders from certain directory so that it could be click able and could see all of the defined item (say - pictures from that folder..) i am being able to explore certain folders and items but how can i send my link towards html page or how to create a dynamic html page.... I have been in process doing this with little program in c# console mode.

    my code is ....
    .................................................. ...............................................
    StringBuilder sb = new StringBuilder();
    sb.AppendLine("<html>");
    sb.AppendLine("<head>");
    sb.AppendLine("<title>Index of c:\\tike</title>");
    sb.AppendLine("</head>");
    sb.AppendLine("<body>");
    sb.AppendLine("<ul>");

    string[] filePaths = Directory.GetFiles(@"c:\tike");
    for (int i = 0; i < filePaths.Length; ++i)
    {
    string name = Path.GetFileName(filePaths[i]);

    sb.AppendLine(string.Format("<li><a href=\"{0}\">{1}</a></li>",
    HttpUtility.HtmlEncode(HttpUtility.UrlEncode(name) ),
    HttpUtility.HtmlEncode(name)));
    }

    sb.AppendLine("</ul>");
    sb.AppendLine("</body>");
    sb.AppendLine("</html>");
    string result = sb.ToString();
    Console.WriteLine(result);
    Console.Read();
    .................................................. .................................................. ....

    As result i see console mode as

    <html>
    <............>
    <li><a href=...................................>

    and all whatever i have appended


    to sum up i wanted to make those things to run in html page...

    any suggestion or snippet would be appreciated.
    regards.
    Tike

  2. #2
    Learning Programmer QuackWare is on a distinguished road
    Join Date
    Jan 2010
    Posts
    83

    Re: c# dynamic html on runtime.

    If you want to create dynamic pages using C# as the codebehind I would suggest using ASP.Net since it is really easy to implement exactly what you are talking about.

  3. #3
    Newbie tomasr is an unknown quantity at this point
    Join Date
    Feb 2010
    Posts
    5

    Re: c# dynamic html on runtime.

    I agree. asp.net does what you're trying to do by hand. you need a way to map the urls to the file paths, and iis is a webserver that you can use to do that, and the code it uses is asp.net. I recommend taking a look at Imar Spaanjaars "Beginning ASP.NET 3.5". That's a good book if you're new to asp.net and programming. if you're a little more advanced at programming, you will skip some parts, but you'll learn how the basic things are done.

  4. #4
    Learning Programmer lobo521 is on a distinguished road
    Join Date
    Jan 2010
    Posts
    46

    Re: c# dynamic html on runtime.

    "win Mo"? You mean Windows mobile? Guys, is there iis for windows mobile?

  5. #5
    Programmer alienkinetics has a little shameless behaviour in the past alienkinetics's Avatar
    Join Date
    Feb 2010
    Location
    Australia
    Posts
    154

    Re: c# dynamic html on runtime.

    If you want to write a HTTP server from scratch, look into the Cassini web server:

    Cassini Sample Web Server : The Official Microsoft ASP.NET Site

    It comes with the C# source code and supports can run ASP.NET.

    I'd start there. If you dont need ASP.NET, then remove it.

  6. #6
    Learning Programmer lobo521 is on a distinguished road
    Join Date
    Jan 2010
    Posts
    46

    Re: c# dynamic html on runtime.


  7. #7
    Learning Programmer QuackWare is on a distinguished road
    Join Date
    Jan 2010
    Posts
    83

    Re: c# dynamic html on runtime.

    Quote Originally Posted by lobo521 View Post
    "win Mo"? You mean Windows mobile? Guys, is there iis for windows mobile?
    If he means Windows Mobile by Win Mo I think he means building a mobile website. No one would host a server from their cell phone.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Having problems with classes
    By eulogy in forum PHP Forum
    Replies: 5
    Last Post: 05-26-2009, 12:39 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts