Closed Thread
Results 1 to 7 of 7

Thread: c# dynamic html on runtime.

  1. #1
    tikejhya is offline Newbie
    Join Date
    Aug 2009
    Posts
    3
    Rep Power
    0

    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. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    QuackWare is offline Learning Programmer
    Join Date
    Jan 2010
    Posts
    95
    Rep Power
    8

    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.

  4. #3
    tomasr is offline Newbie
    Join Date
    Feb 2010
    Posts
    5
    Rep Power
    0

    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.
    Last edited by Roger; 08-13-2010 at 03:01 PM.

  5. #4
    lobo521 is offline Learning Programmer
    Join Date
    Jan 2010
    Posts
    57
    Rep Power
    8

    Re: c# dynamic html on runtime.

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

  6. #5
    alienkinetics's Avatar
    alienkinetics is offline Programmer
    Join Date
    Feb 2010
    Location
    Australia
    Posts
    154
    Rep Power
    0

    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.

  7. #6
    lobo521 is offline Learning Programmer
    Join Date
    Jan 2010
    Posts
    57
    Rep Power
    8

    Re: c# dynamic html on runtime.


  8. #7
    QuackWare is offline Learning Programmer
    Join Date
    Jan 2010
    Posts
    95
    Rep Power
    8

    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.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Runtime property
    By jaiii in forum C and C++
    Replies: 1
    Last Post: 08-19-2010, 04:43 AM
  2. Runtime error
    By lionaneesh in forum C and C++
    Replies: 8
    Last Post: 03-23-2010, 10:55 PM
  3. Runtime
    By Apprentice123 in forum C and C++
    Replies: 8
    Last Post: 11-07-2009, 06:44 AM
  4. Java without runtime?
    By ASCENT in forum Java Help
    Replies: 3
    Last Post: 12-21-2007, 07:35 PM
  5. Dynamic Email insertion in HTML
    By Gibster in forum HTML Programming
    Replies: 5
    Last Post: 07-17-2007, 02:22 PM

Tags for this Thread

Bookmarks

Posting Permissions

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