Web Design and Development Forums

Putting C# into an ASP.NET Page.

This is a discussion on "Putting C# into an ASP.NET Page." within the ASP.NET Forum section. This forum, and the thread "Putting C# into an ASP.NET Page. are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > ASP.NET Forum

Welcome to Webforumz.com.
Register Now Register now!

Closed Thread
 
LinkBack Thread Tools Rate Thread
Old Feb 1st, 2008, 21:36   #1 (permalink)
Administrator
 
alexgeek's Avatar
 
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 4,102
Blog Entries: 9
Send a message via MSN to alexgeek
Putting C# into an ASP.NET Page.

I would like to use the following code to display it on an ASP.NET page.
Currently this code is for a command line application, so I know I need to change Console.WriteLine to something else.
I don't know how to put this on an ASP.NET page, I think I need to use the <script runat="server"> tag somehow though.

Here's the code
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace cli
{
    class Program
    {
        private const string FILE = @"xml/usersettings.xml";
        static void Main(string[] args)
        {
            try
            {
                XmlDocument xml = new XmlDocument();
                xml.Load(FILE);
                XmlNodeList people = xml.GetElementsByTagName("person");
                foreach (XmlNode node in people)
                {
                    XmlElement person = (XmlElement)node;

                    string name = person.GetElementsByTagName("name")[0].InnerText;
                    int age = Convert.ToInt32(person.GetElementsByTagName("age")[0].InnerText);
                    string lang = person.GetElementsByTagName("lang")[0].InnerText;
                    
                    Console.WriteLine("Name: {0}", name.ToString());
                    Console.WriteLine("Age: {0}", age.ToString());
                    Console.WriteLine("language: {0}\n", lang.ToString());
                }
   
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: \n\n {0}", e.ToString());
                System.IO.StreamWriter err = new System.IO.StreamWriter(@"err.txt");
                err.WriteLine("Error Message:\n\n{0}", e.ToString());
                err.Close();
            }
        }
    }
}
edit
This is also the XML being parsed, I thought I may aswell include it (I used peoples names here as I didn't know what else to put ha).
HTML: Select all
<?xml version="1.0" encoding="utf-8" ?>
<usersettings>
  <person>
    <name>Alex</name>
    <age>14</age>
    <lang>PHP</lang>
  </person>
  <person>
    <name>Swagner</name>
    <age>14</age>
    <lang>HTML/CSS</lang>
  </person>
  <person>
    <name>Marc</name>
    <age>15</age>
    <lang>HTML/CSS/~PHP</lang>
  </person>
  <person>
    <name>Craig</name>
    <age>16</age>
    <lang>HTML</lang>
  </person>
</usersettings>
__________________
Languages: PHP, mySQL (queries), C#, (X)html, CSS, JS.


alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old Feb 5th, 2008, 14:48   #2 (permalink)
Junior Member
 
Join Date: Jul 2007
Location: on the forum
Posts: 37
Re: Putting C# into an ASP.NET Page.

So what is your question?
quicker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old Feb 5th, 2008, 17:16   #3 (permalink)
Administrator
 
alexgeek's Avatar
 
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 4,102
Blog Entries: 9
Send a message via MSN to alexgeek
Re: Putting C# into an ASP.NET Page.

I think I explained that, oh well.
I want to put this C# code onto an ASP.NET webpage.
__________________
Languages: PHP, mySQL (queries), C#, (X)html, CSS, JS.


alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
need help putting a video on web page.... earl080688 Flash & Multimedia Forum 1 Oct 10th, 2007 04:04
Putting css in an html page. masonbarge CSS Forum 27 Feb 7th, 2007 22:28
A better way putting a menu bar, on every page Joolsd186 HTML Forum 36 Nov 3rd, 2006 07:29
putting music on a web page Dr. J Introduce Yourself 3 Aug 19th, 2005 20:59
Putting PHP in your web page Jodi PHP Forum 13 Jan 10th, 2005 20:50



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 20:57.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59