Tuesday, September 22, 2009

Convert HTML Form Elements to ASP.NET form elements

Here is my quick method for converting an HTML page to an ASPX page, handling the controls.
1. First I am going to add runat = "server" to the Form tag. I am also going to remove any function calls that were there previously since I will be replacing it with .NET code. I am removing the action and onsubmit elements from the tag.

Transform to


2. Next I am going to find all the text boxes:

Find
Replace with

If your tags are not arranged with the name following "text" you may need to modify it manually or be more specific with your find/replace

If you are closing the input tag, you will need to manually replace it with a closing
tag. Be careful because there are multiple types of inputs in your form, you do not want to replace all of them.
3. Next, I do the same find and replace with the submit button:

to
runat = "server" ID=
4. Translate your submit action into .NET code behind



EDIT:
The copy and pasting of HTML screwed up the entry I made. I will fix it later.

Monday, September 21, 2009

Send Email in C# Code

Send Email in C# Code

Shared via AddThis
Found this useful tiny code snippit for sending emails in C#. Yes this is basics, but it is nice having a little template you can follow easily.

Thursday, September 17, 2009

The Proper Way to Create a Login Screen for your ASP.NET Website

The Proper Way to Create a Login Screen for your ASP.NET Website

Shared via AddThis
This entry has really helped me create a nice login page.

This also has helped me:
http://msdn.microsoft.com/en-us/library/aa302398.aspx

SqlCommand: Expecting Parameter

This is a simple reminder for myself and you all out there.

If you are using SqlCommand to execute stored procedures, remember to set the command type to StoredProcedure!

SqlCommand cmd = new SqlCommand("storedproc", conn);
cmd.CommandType = CommandType.StoredProcedure;