Default.aspx.cs:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Collections;
public partial class _Default : System.Web.UI. Page
{
protected void Page_Load( object sender, EventArgs e)
{
}
protected void btn1_Click( object sender, EventArgs e)
{
string Preference = "" ;
StringBuilder sb = new StringBuilder ();
string TxtMessage = TxtBox1.Text;
string CellPhone = TxtBox2.Text;
string EmailContact = TxtBox3.Text;
string WorkPhone = TxtBox4.Text;
string Fax = TxtBox5.Text;
string pref1 = ". TextMessage: " + TxtMessage + "; " ;
string pref2 = ". CellPhone: " + CellPhone + "; " ;
string pref3 = ". Email: " + EmailContact + "; " ;
string pref4 = ". WorkPhone: " + WorkPhone + "; " ;
string pref5 = ". Fax: " + Fax + "; " ;
Hashtable Zhash = new Hashtable ();
try
{
if (DropDownList1.SelectedItem.Text != null &
DropDownList1.SelectedItem.Text != "" )
Zhash.Add(DropDownList1.SelectedItem.Text, pref1);
if (DropDownList2.SelectedItem.Text != null &
DropDownList2.SelectedItem.Text != "" )
Zhash.Add(DropDownList2.SelectedItem.Text, pref2);
if (DropDownList3.SelectedItem.Text != null &
DropDownList3.SelectedItem.Text != "" )
Zhash.Add(DropDownList3.SelectedItem.Text, pref3);
if (DropDownList4.SelectedItem.Text != null &
DropDownList4.SelectedItem.Text != "" )
Zhash.Add(DropDownList4.SelectedItem.Text, pref4);
if (DropDownList5.SelectedItem.Text != null &
DropDownList5.SelectedItem.Text != "" )
Zhash.Add(DropDownList5.SelectedItem.Text, pref5);
ArrayList sorter = new ArrayList (Zhash.Keys);
sorter.Sort();
foreach ( string key in sorter)
{
sb.Append(key);
sb.Append(Zhash[key]);
}
Preference = sb.ToString();
Response.Write(Preference);
}
catch ( ArgumentException ex)
{
string JString = " " ;
Page.ClientScript.RegisterStartupScript( this .GetType(), "PopupScript" , JString);
}
}
}
Can't post aspx page. It shows as a table instead of code. I just create a table drag and drop textboxes and dropdownlists into table cells. In the catch block above, "string JString" should be initialized. Instead of showing the code it pops up a window here. When I first did the work, it shows the code but doesn't pop up windows. I feel I am both a bad blogger and a bad programmer. :) Will find a way to post it.