T
tony.johansson
Hello!
Below is two files copied the first one is the aspx markup file and the last
one in the code behind .cs file
All this works well.
But if I for example remove the ending / in the row below I get compile
error.
<asp:CheckBox ID="chkPicture" runat="server" Text="Add the default Picture"
/>
I have asked this question before and you have answered that the C# compiler
doesn't care about the HTML syntax.
So I hope to get an answer to my question.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Greeting Card Maker</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<!-- Here are the controls_ -->
Choose a background color: <br />
<aspropDownList ID="lstBackColor" runat="server" Width="194px"
Height="22px" />
<br /> <br />
Choose a font: <br />
<aspropDownList ID="lstFontName" runat="server" Width="194px"
Height="22px" />
<br /> <br />
Specify a numeric font size: <br />
<asp:TextBox ID="txtFontSize" runat="server" />
<br /> <br />
Choose a border style: <br />
<asp:RadioButtonList ID="lstBorder" runat="server" Width="177px"
Height="59px" />
<br /> <br />
<asp:CheckBox ID="chkPicture" runat="server" Text="Add the default
Picture" />
<br /> <br />
Enter the greeting text below: <br />
<asp:TextBox ID="txtGreeting" runat="server" Width="240px"
Height="85px" TextMode="MultiLine" />
<br /> <br />
<asp:Button ID="cmdUpdate" onclick="cmdUpdate_Click" runat="server"
Width="71px" Height="24px" Text="Update" />
</div>
<aspanel ID="pnlCard" runat="server" Height="481px"
HorizontalAlign="Center"
Width="339px" BorderStyle="None">
<br />
<asp:Label ID="lblGreeting" runat="server" Text="Label"
Width="256px" Height="150px" />
<br /> <br /> <br />
<asp:Image ID="imgDefault" runat="server" Width="212px"
Height="160px" />
</aspanel>
</form>
</body>
</html>
//Here is the code behind file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
lstBackColor.Items.Add("White");
lstBackColor.Items.Add("Red");
lstBackColor.Items.Add("Green");
lstBackColor.Items.Add("Blue");
lstBackColor.Items.Add("Yellow");
lstFontName.Items.Add("Times New Roman");
lstFontName.Items.Add("Arial");
lstFontName.Items.Add("Verdena");
lstFontName.Items.Add("Tohoma");
ListItem item = new ListItem();
item.Text = BorderStyle.None.ToString();
item.Value = ((int)BorderStyle.None).ToString();
lstBorder.Items.Add(item);
item = new ListItem();
item.Text = BorderStyle.Double.ToString();
item.Value = ((int)BorderStyle.Double).ToString();
lstBorder.Items.Add(item);
item = new ListItem();
item.Text = BorderStyle.Solid.ToString();
item.Value = ((int)BorderStyle.Solid).ToString();
lstBorder.Items.Add(item);
lstBorder.SelectedIndex = 0;
imgDefault.ImageUrl = "Desert.jpg";
}
}
protected void cmdUpdate_Click(object sender, EventArgs e)
{
pnlCard.BackColor = Color.FromName(lstBackColor.SelectedItem.Text);
lblGreeting.Font.Name = lstFontName.SelectedItem.Text;
if (Int32.Parse(txtFontSize.Text) > 0)
{
lblGreeting.Font.Size =
FontUnit.Point(Int32.Parse(txtFontSize.Text));
}
int borderValue = Int32.Parse(lstBorder.SelectedItem.Value);
pnlCard.BorderStyle = (BorderStyle)borderValue;
if (chkPicture.Checked)
imgDefault.Visible = true;
else
imgDefault.Visible = false;
lblGreeting.Text = txtGreeting.Text;
}
}
Below is two files copied the first one is the aspx markup file and the last
one in the code behind .cs file
All this works well.
But if I for example remove the ending / in the row below I get compile
error.
<asp:CheckBox ID="chkPicture" runat="server" Text="Add the default Picture"
/>
I have asked this question before and you have answered that the C# compiler
doesn't care about the HTML syntax.
So I hope to get an answer to my question.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Greeting Card Maker</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<!-- Here are the controls_ -->
Choose a background color: <br />
<aspropDownList ID="lstBackColor" runat="server" Width="194px"
Height="22px" />
<br /> <br />
Choose a font: <br />
<aspropDownList ID="lstFontName" runat="server" Width="194px"
Height="22px" />
<br /> <br />
Specify a numeric font size: <br />
<asp:TextBox ID="txtFontSize" runat="server" />
<br /> <br />
Choose a border style: <br />
<asp:RadioButtonList ID="lstBorder" runat="server" Width="177px"
Height="59px" />
<br /> <br />
<asp:CheckBox ID="chkPicture" runat="server" Text="Add the default
Picture" />
<br /> <br />
Enter the greeting text below: <br />
<asp:TextBox ID="txtGreeting" runat="server" Width="240px"
Height="85px" TextMode="MultiLine" />
<br /> <br />
<asp:Button ID="cmdUpdate" onclick="cmdUpdate_Click" runat="server"
Width="71px" Height="24px" Text="Update" />
</div>
<aspanel ID="pnlCard" runat="server" Height="481px"
HorizontalAlign="Center"
Width="339px" BorderStyle="None">
<br />
<asp:Label ID="lblGreeting" runat="server" Text="Label"
Width="256px" Height="150px" />
<br /> <br /> <br />
<asp:Image ID="imgDefault" runat="server" Width="212px"
Height="160px" />
</aspanel>
</form>
</body>
</html>
//Here is the code behind file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
lstBackColor.Items.Add("White");
lstBackColor.Items.Add("Red");
lstBackColor.Items.Add("Green");
lstBackColor.Items.Add("Blue");
lstBackColor.Items.Add("Yellow");
lstFontName.Items.Add("Times New Roman");
lstFontName.Items.Add("Arial");
lstFontName.Items.Add("Verdena");
lstFontName.Items.Add("Tohoma");
ListItem item = new ListItem();
item.Text = BorderStyle.None.ToString();
item.Value = ((int)BorderStyle.None).ToString();
lstBorder.Items.Add(item);
item = new ListItem();
item.Text = BorderStyle.Double.ToString();
item.Value = ((int)BorderStyle.Double).ToString();
lstBorder.Items.Add(item);
item = new ListItem();
item.Text = BorderStyle.Solid.ToString();
item.Value = ((int)BorderStyle.Solid).ToString();
lstBorder.Items.Add(item);
lstBorder.SelectedIndex = 0;
imgDefault.ImageUrl = "Desert.jpg";
}
}
protected void cmdUpdate_Click(object sender, EventArgs e)
{
pnlCard.BackColor = Color.FromName(lstBackColor.SelectedItem.Text);
lblGreeting.Font.Name = lstFontName.SelectedItem.Text;
if (Int32.Parse(txtFontSize.Text) > 0)
{
lblGreeting.Font.Size =
FontUnit.Point(Int32.Parse(txtFontSize.Text));
}
int borderValue = Int32.Parse(lstBorder.SelectedItem.Value);
pnlCard.BorderStyle = (BorderStyle)borderValue;
if (chkPicture.Checked)
imgDefault.Visible = true;
else
imgDefault.Visible = false;
lblGreeting.Text = txtGreeting.Text;
}
}