I am new with Asp.net C#. Looking to create a Message Board where user can enter and make the message BOLD, Italic, and Underline. Also will be able to change the Forecolor For the text. Also the Font Name can be changed to according to what user picked from the Drop Down list.
Please help.
Thanks
What I have tried:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
namespace ProjectBoard
{
public partial class MessageBoardaspx : System.Web.UI.Page
{
private Style PrimaryStyle = new Style();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
// Adding Colors
ListItemCollection colors = new ListItemCollection();
colors.Add(System.Drawing.Color.Black.Name);
colors.Add(System.Drawing.Color.Blue.Name);
colors.Add(System.Drawing.Color.Green.Name);
colors.Add(System.Drawing.Color.Orange.Name);
colors.Add(System.Drawing.Color.Purple.Name);
colors.Add(System.Drawing.Color.Red.Name);
colors.Add(System.Drawing.Color.White.Name);
colors.Add(System.Drawing.Color.Yellow.Name);
Color.DataSource = colors;
Color.DataBind();
// Add FontName
ListItemCollection names = new ListItemCollection();
names.Add("Arial");
names.Add("Courier");
names.Add("Garamond");
names.Add("Times NEw Roman");
names.Add("Verdana");
FontNameList.DataSource = names;
FontNameList.DataBind();
// Add FontSize
ListItemCollection FontSizes = new ListItemCollection();
FontSizes.Add("Small");
FontSizes.Add("Medium");
FontSizes.Add("Large");
FontSizes.Add("10pt");
FontSizes.Add("14Pt");
FontSizes.Add("20pt");
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
lblEnterMessage.Text = lblMessage.Text;
lblMessage.Text = txtMessage.Text;
string changestyles = "" + lblMessage.Text + "";
string url = string.Format("MessageDisplay.aspx?data={0}&color={1}", lblMessage.Text, Color.SelectedValue);
Response.Redirect(url);
}
protected void txtMessage_TextChanged(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
PrimaryStyle.ForeColor = System.Drawing.Color.FromName(Color.SelectedItem.Text);
lblMessage.ApplyStyle(PrimaryStyle);
txtMessage.ApplyStyle(PrimaryStyle);
lblMessage.ForeColor = System.Drawing.Color.FromName(Color.Text);
}
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
PrimaryStyle.Font.Name = FontNameList.SelectedItem.Text;
lblMessage.ApplyStyle(PrimaryStyle);
txtMessage.ApplyStyle(PrimaryStyle);
}
protected void FontSizeList_SelectedIndexChanged(object sender, EventArgs e)
{
PrimaryStyle.Font.Size = FontUnit.Parse(FontSizeList.SelectedItem.Text);
lblMessage.ApplyStyle(PrimaryStyle);
txtMessage.ApplyStyle(PrimaryStyle);
}
protected void btntest_Click(object sender, EventArgs e)
{
lblMessage.Text = Color.SelectedValue;
}
protected void btnBold_Click(object sender, EventArgs e)
{
}
}
}