Alert

There are no notes for this item.

<div id="MsuAlert" class="alert" aria-label="Homepage Alert" role="alert">
    <div id="MsuAlertOuter" class="container">
        <div id="MsuAlertInner" class="inner">
            <h2>Missouri State alert</h2>
            <p class="headline"><a href="#">Lorem ipsum dolor sit amet consectetur</a>
            </p>
            <p class="description">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Ullam perferendis repellat vero in non ipsum recusandae quos fugiat doloribus quasi.</p>
        </div>
    </div>
</div>
<div id="MsuAlert" class="alert" aria-label="Homepage Alert" role="alert">
  <div id="MsuAlertOuter" class="container">
    <div id="MsuAlertInner" class="inner">
      <h2>Missouri State alert</h2>
      <p class="headline"><a href="{{url}}">{{headline}}</a>
      </p>
      <p class="description">{{description}}</p>
    </div>
  </div>
</div>
{
  "headline": "Lorem ipsum dolor sit amet consectetur",
  "url": "#",
  "description": "Lorem ipsum dolor sit amet consectetur, adipisicing elit. Ullam perferendis repellat vero in non ipsum recusandae quos fugiat doloribus quasi."
}
  • Content:
    <script runat="server" language="C#">
    	protected System.Collections.Generic.List < Alert > MsuAlertList = new System.Collections.Generic.List<Alert>();
      String DateToday = DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss.000", System.Globalization.CultureInfo.InvariantCulture);
      Boolean HasAlerts = false;
      Regex CampusRgx = new Regex(@"/(www\.|staging\.)?missouristate\.edu/");
      Regex SelectedDateRgx = new Regex(@"^([\d]{1}|[\d]{2}|[\d]{4})(-|\/|\.)[\d]{1,2}(-|\/|\.)([\d]{2}|[\d]{4})$");
        private String AlertsQuery;
        private System.Data.SqlClient.SqlConnection AlertsQueryConnection;
    
        public String TheDate
      {
        get
        {
          String TheDateVar = "";
          Uri TheRealURL = new Uri(HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.RawUrl);
          String ParamDateVar = HttpUtility.ParseQueryString(TheRealURL.Query).Get("selecteddate");
    
    
          if (String.IsNullOrEmpty(ParamDateVar) == false && SelectedDateRgx.IsMatch(ParamDateVar) == true) {
            TheDateVar = ParamDateVar + " " + DateTime.Now.ToString("HH:mm:ss.000", System.Globalization.CultureInfo.InvariantCulture);
          } else {
            TheDateVar = DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss.000", System.Globalization.CultureInfo.InvariantCulture);
          }
    
          return TheDateVar;
        }
        set{ }
      }
    
    	protected void Page_Load(object sender, EventArgs e) {
        //String TheDateToUse = TheDate;
    
        AlertsQuery = string.Format("SELECT Headline, ShortMessage FROM HomepageNotices WHERE '{0}' >= BeginDate AND '{0}' <= EndDate AND Campus='{1}' ORDER BY EndDate DESC", TheDate, CampusRgx.IsMatch(HttpContext.Current.Request.Url.ToString()) == true ? "s" : "w");
        AlertsQueryConnection = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["MSUAlerts"].ConnectionString);
    
        using(AlertsQueryConnection)
        {
          System.Data.SqlClient.SqlCommand AlertsCommand = new System.Data.SqlClient.SqlCommand(AlertsQuery, AlertsQueryConnection);
          AlertsQueryConnection.Open();
          System.Data.SqlClient.SqlDataReader AlertsDataReader = AlertsCommand.ExecuteReader();
          if (AlertsDataReader.HasRows) {
            HasAlerts = true;
            while (AlertsDataReader.Read()) {
              Alert MsuAlert = new Alert(AlertsDataReader["Headline"].ToString(), AlertsDataReader["ShortMessage"].ToString());
              MsuAlertList.Add(MsuAlert);
            }
          }
          AlertsDataReader.Close();
          ((Repeater) Page.FindControl("MSUAlertRepeater")).DataSource = MsuAlertList;
          ((Repeater) Page.FindControl("MSUAlertRepeater")).DataBind();
        }
      }
    
      public class Alert {
        public Alert(string headline, string shortMessage) {
          Headline = headline;
          ShortMessage = shortMessage;
        }
        public string Headline {
        get;
        set;
      }
            public string ShortMessage {
        get;
        set;
      }
        }
    </script>
    <%-- DEBUG ONLY
    <%= TheDate %><br />
    <%= DateToday %><br />
    <%= HttpContext.Current.Request.Url %><br />
    <%= CampusRgx.IsMatch(HttpContext.Current.Request.Url.ToString()) %><br />
    <%= SelectedDateRgx %><br />
    --%>
    <% if (HasAlerts) { %>
    <div id="MsuAlert" class="alert" aria-label="Homepage Alert" role="alert">
      <div id="MsuAlertOuter" class="container">
        <div id="MsuAlertInner" class="inner">
          <h2>Missouri State alert</h2>
          <asp:Repeater id="MSUAlertRepeater" runat="server">
            <ItemTemplate>
              <p class="headline">
                <a href="https://www.missouristate.edu/contact/status.aspx"><%# Eval(" Headline ") %></a>
              </p>
              <p class="description"><%# Eval(" ShortMessage ") %></p>
            </ItemTemplate>
          </asp:Repeater>
        </div>
      </div>
    </div>
    <% } %>
    <script defer src="{{path '/scripts/components/alert.js'}}" async></script>
  • URL: /components/raw/alert/alert--dynamic.aspx
  • Filesystem Path: src\components\02-blocks\alert\alert--dynamic.aspx
  • Size: 3.9 KB