Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Form Action Page

Posted on December 17, 2013October 26, 2015 By David Kittell

This page will walk you through how to build one action page to handle various forms.

WORK IN PROCESS!

Form HTML fields should start with “form_” for this to work.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Collections.Specialized;
protected void Submit_Click(object sender, EventArgs e)
	{
		if (Page.IsPostBack)
		{
			form.Visible = false;
			NameValueCollection submittedValuesCollection = Request.Form;

			Response.Write("<b>Submitted Values:<br /></b>");

			Response.Write(Request.Form["start"] + "<br/>");
			Response.Write(Request.Form["end"] + "<br/>");

			string sInputControl = "";
			string sInputValue = "";
			string[] sDataElement;
			string sSQL = "";

			foreach (string key in submittedValuesCollection.AllKeys)
			{
				sInputControl = string.Format("{0}", key, submittedValuesCollection[key]);
				sInputValue = string.Format("{1}", key, submittedValuesCollection[key]);

				try
				{
					if (sInputValue != "")
					{

						if (sInputControl.Contains("form_"))
						{
							sDataElement = sInputControl.Split('_');

							Response.Write("<p>Field: " + sDataElement[1]);
							Response.Write("<br>Value: " + sInputValue);


							/*	sSQL = "INSERT INTO table (category, measure, submitted, start, [end], [count], submittedby) Values ('"
								+ sDataElement[1]
								+ "','"
								+ sDataElement[2]
								+ "','"
								+ DateTime.Now.ToString()
								+ "','"
								+ Request.Form["start"]
								+ "','"
								+ Request.Form["end"]
								+ "','"
								+ sInputValue
								+ "','"
								+ sEmployee
								+ "');";
							 */

							//Response.Write("<br/>SQL: " + sSQL);
							//	sRunSQLStmnt(sSQL);

							Response.Write("</p>");
						}

					}
				}
				catch (Exception ex)
				{
					Response.Write("<p>" + ex.ToString() + "</p>");
				}


			}
			Response.Write("<br /><br />");
		}
	}
Originally Posted on December 17, 2013
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code CSharp MSSQL SQL

Post navigation

Previous post
Next post

Related Posts

Ektron – DMS Content List

Posted on October 31, 2014October 26, 2015

<%@ Page Title="" Language="C#" CodeFile="DMSFileList.aspx.cs" Inherits="DMSFileList" %> <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <meta charset="utf-8" /> <title>DMS File List</title> </head> <body> <form id="form1" runat="server"> <asp:Repeater ID="subContentRepeater" runat="server"> <HeaderTemplate> <table style="border: 1px solid #000000;"> <tr> <th>ID</th> <th>Type</th> <th>QuickLink</th> <th>Title</th> <th>Summary</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td style="vertical-align: text-top;"> <%# DataBinder.Eval(Container.DataItem,…

Read More

Connect to SSH from Terminal

Posted on October 28, 2015

When on a UNIX based computer you can connect to another terminal via SSH using this command ssh -p 22 user@your.ip.address The -p defines the port, while 22 is the default port for SSH some servers change their port to ward off potential hackers. Make sure you know what the…

Read More

SQLite – Auto-Increment / Auto Generate GUID

Posted on December 19, 2014May 13, 2016

Recently was asked if it’s possible to create an auto-incrementing GUID in SQLite. Here is one approach: In Firefox there is an add-on called SQLite Manager (also available at https://code.google.com/p/sqlite-manager/) Open Firefox, in the “Tools” menu select “SQLite Manager” With SQLite Manager open click on the “Database” menu and select…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes