ict.ken.be

Delivering solid user friendly software solutions since the dawn of time.

Example Messagent dynamic page with c#

Categories: .Net Messagent
Website with registration
designer - select a date

<FORM method=post name=silentboxesform action=[$=PROBE(200)/]>
<DIV id=MASECTION contentEditable=true MACONSTRAINT="DATA_ERROR<>''" MASHOWALLLANGUAGES="FALSE">
<B>Kies een datum...</B>
<P>~DYNAMIC_RADIOLIST~</P>
<INPUT style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; WIDTH: 78px; BACKGROUND: url(http://messagent.yourinstallation.be/images/Residential/Adhoc/2008/2008-05/silent%20boxes/btn.gif); HEIGHT: 24px; COLOR: #7a7a7a; FONT-SIZE: 9px; BORDER-TOP: 0px; FONT-WEIGHT: bold; BORDER-RIGHT: 0px" value=Verdergaan alt=Verdergaan type=submit>
</DIV>
</FORM>


timeslots.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
 using (var con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]))
 {
         con.Open();

                var sbQuery = new StringBuilder();
                sbQuery.Append("select year(dag) as jaar, month(dag) as maand, day(dag) as dag, min(id) as slotid");
                sbQuery.Append(" from timeslots");
                sbQuery.Append(" where fk_user_id is null");
                sbQuery.Append(" and DatePart(hour, dag) < 12");
                sbQuery.Append(" group by year(dag), month(dag), day(dag)");

                bool hasVoormiddag = false;

                using (var cmd = new SqlCommand(sbQuery.ToString(), con))
                {
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (dr != null)
                        {
                            hasVoormiddag = true;

                            Response.Write("Voormiddag : <br />");

                            while (dr.Read())
                            {
                                Response.Write(
                                    "<input type='radio' name='slot' value='" + dr["slotid"] + "' onclick=\"new Effect.BlindDown($('internetDiv'),'blind', {duration:0.3});\" /> " + dr["dag"] + " september");
                                Response.Write("<br />");
                            }
                        }
                    }
                }

                sbQuery = new StringBuilder(); 
                sbQuery.Append(" select year(dag) as jaar, month(dag) as maand, day(dag) as dag, min(id) as slotid");
                sbQuery.Append(" from timeslots");
                sbQuery.Append(" where fk_user_id is null");
                sbQuery.Append(" and DatePart(hour, dag) > 12");
                sbQuery.Append(" group by year(dag), month(dag), day(dag)");

                if (hasVoormiddag) Response.Write("<br />");
               
                using (var cmd = new SqlCommand(sbQuery.ToString(), con))
                {
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (dr != null)
                        {
                            Response.Write("Namiddag : <br />");

                            while (dr.Read())
                            {
                                Response.Write(
                                    "<input type='radio' name='slot' value='" + dr["slotid"] + "' onclick=\"new Effect.BlindDown($('internetDiv'),'blind', {duration:0.3});\" /> " + dr["dag"] + " september");
                                Response.Write("<br />");
                            }
                        }
                    }
                }

            }
}

Website with registration