C# is case-sensitive. C# is case-sensitive. C# is case-sensitive.
I have to keep reminding myself of this.
I'm not used to case-sensitivity yet and it continues to challenge me.
C# is case-sensitive. C# is case-sensitive. C# is case-sensitive.
I have to keep reminding myself of this.
I'm not used to case-sensitivity yet and it continues to challenge me.
Wednesday, March 10 2010 by Brad Kingsley | 0 comment(s)
Tagged as: asp-net-4-0, c, iis, hosting, development, learning
ASP.Net has a built-in feature named Forms Authentication that allows a developer to easily secure certain areas of a web site. In this post I'm going to build a simple authentication sample using C# and ASP.Net 4.0 (still in beta as of the posting date).
Monday, February 15 2010 by Brad Kingsley | 0 comment(s)
Tagged as: hosting, asp-net, security, c, development
Someone pointed out my old-school VB naming conventions in a recent C# sample code post and provided some pointers and some suggested reading. I've named objects the same way for so long that I'm sure I'll struggle with the changes, but I took the pointers to heart and will work to adjust my naming conventions moving forward. I haven't read through the link provided yet, but figured I'd share it here (its from MSDN).
He also mentioned that the comments button isn't currently working, which explains why comments have totally dropped off - someone here is looking into that issue to see why it broke and will hopefully have it working again shortly.
Update: Here is another link I was just reading about Pascal Case and Camel Case use in C# programming:
http://cplus.about.com/od/learnc/ss/csharpclasses_5.htm
Wednesday, February 10 2010 by Brad Kingsley | 0 comment(s)
Tagged as: asp-net, c, development, windows, hosting
(I updated the code sample based on feedback about C# naming standards and leveraging iDisposable - which I'm sure I'll forget many times until I get comfortable more with C#.)
Below is sample code showing how to send email from ASP.Net 4 (currently in beta as of this posting) using C#. With this code I am assuming that the server already has a local SMTP service installed, so I use "localhost" to relay the email.
Here is the SendMail.aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SendMail.aspx.cs" Inherits="SendMail" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Message to:
<asp:TextBox ID="to" runat="server"></asp:TextBox>
<br />
Message from:
<asp:TextBox ID="from" runat="server"></asp:TextBox>
<br />
Subject:
<asp:TextBox ID="subject" runat="server"></asp:TextBox>
<br />
Message Body:
<br />
<asp:TextBox ID="body" runat="server" Height="171px" TextMode="MultiLine"
Width="270px"></asp:TextBox>
<br />
<asp:Button ID="sendMail" runat="server" onclick="SendMail_Click"
Text="Send Email" />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
Here is the source code of the SendMail.aspx.cs page:
using System;
using System.Web.UI.WebControls;
using System.Net.Mail;
public partial class SendMail : System.Web.UI.Page
{
protected void SendMail_Click(object sender, EventArgs e)
{
using (MailMessage mailItem = new MailMessage(
from.Text, to.Text, subject.Text, body.Text))
{
SmtpClient smtpServer = new SmtpClient("localhost");
try
{
smtpServer.Send(mailItem);
}
catch (Exception ex)
{
Label1.Text = ex.ToString();
}
}
}
}
Monday, February 08 2010 by Brad Kingsley | 0 comment(s)
Tagged as: hosting, iis, c, asp-net, email, smtp, code-sample
The SMTP services are not installed by default on Windows Server 2008. To install that service, follow these steps...
First go to the Features Summary section of the Server Manager and click Add Features.
Then scroll down and select the SMTP Server option from the list.
Once you click the SMTP Server option, you'll get a dialog box showing the other roles and features required for the SMTP service to work.
Click Add Required Role Services then Next on the three subsequent dialog boxes. You're then presented with a summary and an Install button. Click Install and all the required services will be installed to support SMTP on the server.
Thursday, February 04 2010 by Brad Kingsley | 0 comment(s)
Tagged as: hosting, iis, asp-net, email, c
I learned my second key C# item just now ... Using = means an assignment. Using == means a comparison.
So...
Label1.Text == "Yes!"
... means DOES label1.text equal "Yes!"
and...
Label1.Text = "Yes!"
... means assign label1.text equal to "Yes!"
It's very helpful to know these little things. :-)
Wednesday, January 27 2010 by Brad Kingsley | 0 comment(s)
Tagged as: development, c, net, programming
Wednesday, February 14 2007 by Jeremy Hodges | 0 comment(s)
Tagged as: script, sidebar-gadgets, c, windows-vista