Add “Please select” message to databound dropdown list c#

So you have dropdown lists, populated with data from your data storage solution.  You need to prepend the lists with messages such as “Please select an option”.

 

 public void addMessageToDropdown(DropDownList whatDropdown, string ddmessage)
 {
    DropDownList list = whatDropdown as DropDownList;
    if(list != null)
    {
      list.Items.Insert(0, ddmessage);
    }
 
 }

 

Add years to dropdown

Need a dropdown list with some years in it and a custom message as the first choice? How about this to start with: current year through 6 years into the future. Add a dropdownlist control to the page and call this function on pageload.

public void addYearsToDropdown(DropDownList whatDropdown, string ddmessage)
 {
      DropDownList list = whatDropdown as DropDownList;
      if(list != null)
      {
          list.Items.Insert(0, ddmessage);
      }
      int curYear = System.DateTime.Now.Year - 1;
      for(int i = 1; i < 6; i++)
      {
          list.Items.Insert(i, (curYear + i).ToString());
       }
 }

addMessageToDropdown(DropDownListYears, “–Select A Year–“);

Firewall and Web application security

Cloudflare is a cloud based web application security firewall.

https://www.cloudflare.com/security/

Security

Cloudflare Security Services reduce the risk of lost customers, declining revenues, and degraded brand by protecting against DDoS attacks, abusive bots, and data breach.

  • Anycast Network

    With 122 data centers across 58 countries and 15 Tbps of capacity, Cloudflare’s Anycast network absorbs distributed attack traffic by dispersing it geographically, while keeping Internet properties available and performant.
  • DNSSEC

    DNSSEC is the Internet’s non-spoofable caller ID. It guarantees a web application’s traffic is safely routed to the correct servers so that a site’s visitors are not intercepted by a hidden “man-in-the-middle” attacker.
  • Web Application Firewall (WAF)

    Cloudflare’s enterprise-grade web application firewall (WAF) detects and block common application layer vulnerabilities at the network edge, utilising the OWASP Top 10, application-specific and custom rulesets.
  • Rate Limiting

    Rate Limiting protects critical resources by providing fine-grained control to block or qualify visitors with suspicious request rates.
  • SSL / TLS

    Transport Security Layer (TLS) encryption enables HTTPS connections between visitors and origin server(s), preventing man-in-the-middle attacks, packet sniffing, the display of web browser trust warnings, and more.
  • Secure Registrar

    Cloudflare is an ICANN accredited registrar, protecting organizations from domain hijacking with high-touch, online and offline verification for any changes to a registrar account.
  • Orbit

    Cloudflare Orbit solves security-related issues for Internet of Things devices at the network level.
  • Warp

    Automatically secure, accelerate, route, and load balance applications and services without directly exposing them to the internet.
  • Workers

    Cloudflare Workers let developers run JavaScript Service Workers in Cloudflare’s 122 data centers around the world.
  • Access

    Secure, authenticate, and monitor user access to any domain, application, or path on Cloudflare.

Checking boxes in a C# ASP checkbox list using values from a database

Suppose you have an ASP checkbox list and you need to check the boxes using data returned from the information storage.

You have a couple of ways the data could have been stored. If each checkbox option is a separate field in the database, you could go with a simple loop, but if they have been stored in one field, you need to put some programming power into it.

Here’s a scenario. I have a “seasons” checklist. There are values stored in the db that the user selected. For example if they chose Summer and Fall, the db string “seasons” would contain “Summer Fall”.

<asp:CheckBoxList ID="CheckBoxListSeasons" runat="server">
 <asp:ListItem>Summer</asp:ListItem>
 <asp:ListItem>Fall</asp:ListItem>
 <asp:ListItem>Winter</asp:ListItem>
 <asp:ListItem>Spring</asp:ListItem>
 </asp:CheckBoxList>

In order to display the list with the Summer and Fall boxes checked, I would do this:

string seasons = "Summer Fall"
for (int i = 0; i < CheckBoxListSeasons.Items.Count; i++)
 {

if (seasons.Contains(CheckBoxListSeasons.Items[i].Value))
 {

CheckBoxListSeasons.Items[i].Selected = true;
 }
 } // end checkbox loop

 

 

 

Transformation Matrices

Rotate a figure 180 degrees around the origin:

From your original figure, just reverse the polarity of the ordered pairs.

Point A(x,y) will be Point a(-x, -y)

(-6,3) (-3,3) (-2,5) (-2,1) (-6,1) original
(6,-3) (3,-3) (2,-5) (2,-1) (6,-1) rotated 180 degrees around origin.

 

Reflect over y-axis

From the original, reverse the polarity of the x value. Point A(x,y) will become point a(-x,y)

(-6,3) (-3,3) (-2,5) (-2,1) (-6,1) original
(6,3) (3,3) (2,5) (2,1) (6,1) reflected over y axis

 

Rotate 90 degrees counter clockwise around origin

The new position of point M (h, k) will become M’ (k, -h)