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); }
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(); }
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(); }
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(); }
//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()); }
//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()); }
//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()); }
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")); }