TreeView kontrolünü Menu gibi kullanmak istersek css ile kolayca yapılabiliriz. Şahsen ben herzaman Menu kontrolüne tercih etmişimdir :)
head:
<style type="text/css">
.menu_nodeStyle
{
color:Black;
font-family:Verdana;
font-size:10pt;
padding:2px 2px 2px 2px;
width:100%;
border:solid 1px #dad6d5;
height:25px;
}
.menu_hoverNodeStyle
{
background-color:#CCCCCC;
border:solid 1px #888888;
cursor:pointer;
}
.menu_selectedNodeStyle
{
padding:2px 2px 2px 2px;
font-weight:bold;
color:#0a6082;
}
.menu
{
padding-top: 10px;
background-color: #dad6d5;
width:200px;
}
</style>
body:
<div class="menu">
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1">
<NodeStyle CssClass="menu_nodeStyle" />
<HoverNodeStyle CssClass="menu_hoverNodeStyle" />
<SelectedNodeStyle CssClass="menu_selectedNodeStyle" />
</asp:TreeView>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</div>
result
Site içinde kullandığım E-mail uygulamasının kodları...
//css
#dvFrame
{
width: 600px;
margin: 0 auto;
padding: 5px;
text-align: left;
border: solid 1px gray;
background-color: White;
}
#lblHead
{
clear: left;
color: #495a92;
float: left;
font-size: 15px;
font-weight: bold;
text-decoration: none;
}
#imgSPRT
{
height: 1px;
width: 99%;
padding-top: 5px;
padding-bottom: 10px;
}
#btnSend
{
margin-left: 120px;
margin-top: 5px;
width: 90px;
border: solid 1px #c0c0c0;
font-size: 12px;
}
#valSum
{
font-size: 12px;
color: Maroon;
}
#lblWarning
{
text-align: center;
width: 100%;
font-size: 12px;
color: Maroon;
}
.mailLabel
{
float: left;
width: 120px;
font-weight: bold;
font-size: 12px;
}
.mailText
{
width: 180px;
margin-bottom: 5px;
border: solid 1px #c0c0c0;
font-size: 12px;
}
.mailDesc
{
width: 350px;
height: 150px;
border: solid 1px #c0c0c0;
font-size: 12px;
}
//aspx
<div id="dvFrame">
<asp:Label ID="lblHead" runat="server" Text="E-mail" /><br />
<img id="imgSPRT" src="images/bar.gif" alt="sprt" />
<asp:Label ID="lblName" runat="server" CssClass="mailLabel" Text="Ad" />
<asp:TextBox ID="txtName" runat="server" CssClass="mailText" />
<asp:RequiredFieldValidator ID="rqrName" runat="server" ControlToValidate="txtName"
Display="None" ErrorMessage="Ad Gerekli." ValidationGroup="mail" /><br />
<asp:Label ID="lblMail" runat="server" CssClass="mailLabel" Text="E-mail" />
<asp:TextBox ID="txtMail" runat="server" CssClass="mailText" />
<asp:RequiredFieldValidator ID="rqrMail" runat="server" ControlToValidate="txtMail"
Display="None" ErrorMessage="E-mail Gerekli." ValidationGroup="mail" />
<asp:RegularExpressionValidator ID="rqeMail" runat="server" ControlToValidate="txtMail"
Display="None" ErrorMessage="Geçersiz E-mail." ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="mail" /><br />
<asp:Label ID="lblMessage" runat="server" CssClass="mailLabel" Text="Mesaj" />
<asp:TextBox ID="txtMessage" runat="server" CssClass="mailDesc" TextMode="MultiLine" />
<asp:RequiredFieldValidator ID="rqrMessage" runat="server" ControlToValidate="txtMessage"
Display="None" ErrorMessage="Mesaj Gerekli." ValidationGroup="mail" /><br />
<asp:Button ID="btnSend" runat="server" Text="Gönder" OnClick="btnSend_Click" ValidationGroup="mail" /><br />
<asp:ValidationSummary ID="valSum" runat="server" ValidationGroup="mail" /><br />
<asp:Label ID="lblWarning" runat="server"></asp:Label>
</div>
//cs
StringBuilder messageBody = new StringBuilder();
messageBody.Append("Name : ");
messageBody.Append(txtName.Text.Trim());
messageBody.Append("\n");
messageBody.Append("Email : ");
messageBody.Append(txtMail.Text.Trim());
messageBody.Append("\n");
messageBody.Append("Message : ");
messageBody.Append(txtMessage.Text.Trim());
messageBody.Append("\n");
//from ile To aynı adres olabilir.
MailMessage newMessage = new MailMessage("from@mailserver.com", "to@mailserver.com", "Contact", messageBody.ToString());
SmtpClient newSmtp = new SmtpClient("mail.mailserver.com");
newSmtp.Credentials = new System.Net.NetworkCredential("from@mailserver.com", "password");
try
{
newSmtp.Send(newMessage);
lblWarning.Text = "Tamam, Mesajınız bana iletildi...";
}
catch
{
lblWarning.Text = "Hata, tekrar deneyin.";
}