예제 #1
0
 static void Main(string[] args)
 {
     ElementBuilder div = new ElementBuilder("div");
     div.AddAtribute("id","page");
     div.AddAtribute("class","big");
     div.AddContent("<p>Hello!</p>");
     Console.WriteLine(div*2);
 }
예제 #2
0
 public static string CreateURL(string url, string title, string text)
 {
     ElementBuilder a = new ElementBuilder("a");
     a.addAttribute("href", url);
     a.addAttribute("title", title);
     a.addAttribute("", text);
     return a.ToString();
 }
예제 #3
0
 public static string CreateInput(string type, string name, string value)
 {
     ElementBuilder input = new ElementBuilder("input");
     input.addAttribute("type", type);
     input.addAttribute("name", name);
     input.addAttribute("value", value);
     return input.ToString();
 }
예제 #4
0
 public static string CreateImage(string src, string alt, string title)
 {
     ElementBuilder image = new ElementBuilder("img");
     image.addAttribute("src", src);
     image.addAttribute("alt", alt);
     image.addAttribute("title", title);
     image.closingTags(true);
     return image.ToString();
 }
예제 #5
0
        //third method -> CreateInput() takes input type, name and value.
        public static string CreateInput(string inputType, string inputName, string inputValue)
        {
            ElementBuilder input = new ElementBuilder("input");

            input.AddAttribute("type", inputType);
            input.AddAttribute("name", inputName);
            input.AddAttribute("value", inputValue);

            return(input.ToString());
        }
예제 #6
0
        //second method -> CreateURL() tekes url, title and text.
        public static string CreateURL(string url, string title, string text)
        {
            ElementBuilder urlObj = new ElementBuilder("a");

            urlObj.AddAttribute("href", url);
            urlObj.AddAttribute("title", title);
            urlObj.AddContent(text);

            return(urlObj.ToString());
        }
예제 #7
0
        //Write a static class HTMLDispatcher that holds 3 static methods,
        //which takes a set of arguments and return the HTML element as string:

        //first method -> CreateImage() takes image source, alt and title.
        public static string CreateImage(string imageSource, string alt, string title)
        {
            ElementBuilder img = new ElementBuilder("img");

            img.AddAttribute("src", imageSource);
            img.AddAttribute("alt", alt);
            img.AddAttribute("title", title);

            return(img.ToString());
        }
예제 #8
0
        static void Main(string[] args)
        {
            ElementBuilder div = new ElementBuilder("div");
            div.addAttribute("id", "page");
            div.addAttribute("class", "big");
            div.addContent("<p>Hello!</p>");
            Console.WriteLine(div * 2);

            Console.WriteLine(HTML_Dispatcher.CreateImage("image.png", "picture", "picture title"));
            Console.WriteLine(HTML_Dispatcher.CreateURL("../../url.url", "url title", "Click here!"));
            Console.WriteLine(HTML_Dispatcher.CreateInput("input", "input_text", "null"));
        }