A Simple 2-Column Layout in Razor

2 column layouts are rather popular on the web, and there are 1,001 ways to make them work. The approach you choose really depends on the type of content you have, and how you want images and backgrounds to work. What I’ll show is the Razor _Layout and CSS to achieve the following look:

The Razor _Layout file can rely on partial views to handle each of the primary sections: top, navigation, sidebar, and footer. RenderBody will produce the primary content area.

<!DOCTYPE html>
<html>
<head>    
    <title>@ViewBag.Title</title>    
    <link href="@Url.Content("~/Content/Site.css")" 
          rel="stylesheet" type="text/css" />
</head>

<body>
    @Html.Partial("_top")
    @Html.Partial("_navigation")
    @Html.Partial("_sidebar")                               
    <div id="body">
        @RenderBody()      
    </div>    
    @Html.Partial("_footer")   
</body>
</html>

A quick note on Html.Partial. If any sections, like the sidebar and navigation sections, require some logic or model information to build their piece of the UI, then use Html.Action instead of Html.Partial. Html.Action allows you to setup a little sub-request inside the current request and allow a controller action to build a model and select a view.

The CSS coming up assumes each partial view will render inside an element with an id matching it’s purpose (so the _top view renders a div with an id of top).

<div id="top">
    This is the top content
</div>

Then finally, add some styles to the CSS file:

#top {
    height: 20px;
    text-align: center;
    background-color: black;
    color: white;   
}

#navigation {
    height: 25px;
    margin: 5px;
    padding: 5px;
    color:crimson;
}

#sidebar {
    margin: 5px;
    padding: 5px;
    position: absolute;
    top: 50px;
    left: 314px;
}

#body {
    width: 300px;
    padding: 5px;
    margin: 5px;
    background-color: #999999;
    border-radius: 5px;
    border: 2px black solid;
}

#footer {
    padding: 5px;
    text-align: center;
    background-color: black;
    color: white;
}

The trick is to use absolute positioning on the sidebar content, which is possible because we know the exact amount of space taken by the 2 sections at the top of the page, and we know the exact width of the content area (it is set explicitly in the CSS). You’ll probably want to give the body more space than the 300px given in the sample above (which was constrained so the screenshot would fit on this page).

Resources

https://dev.to/codeply/bootstrap-5-sidebar-examples-38pb

JSON Example

This page shows example of JSON and XML. This is a handy reference only;

{
    "glossary": {
        "title": "example glossary",
		"GlossDiv": {
            "title": "S",
			"GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
					"SortAs": "SGML",
					"GlossTerm": "Standard Generalized Markup Language",
					"Acronym": "SGML",
					"Abbrev": "ISO 8879:1986",
					"GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
						"GlossSeeAlso": ["GML", "XML"]
                    },
					"GlossSee": "markup"
                }
            }
        }
    }
}
The same text expressed as XML:

<!DOCTYPE glossary PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
 <glossary><title>example glossary</title>
  <GlossDiv><title>S</title>
   <GlossList>
    <GlossEntry ID="SGML" SortAs="SGML">
     <GlossTerm>Standard Generalized Markup Language</GlossTerm>
     <Acronym>SGML</Acronym>
     <Abbrev>ISO 8879:1986</Abbrev>
     <GlossDef>
      <para>A meta-markup language, used to create markup
languages such as DocBook.</para>
      <GlossSeeAlso OtherTerm="GML">
      <GlossSeeAlso OtherTerm="XML">
     </GlossDef>
     <GlossSee OtherTerm="markup">
    </GlossEntry>
   </GlossList>
  </GlossDiv>
 </glossary>
{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}
The same text expressed as XML:

<menu id="file" value="File">
  <popup>
    <menuitem value="New" onclick="CreateNewDoc()" />
    <menuitem value="Open" onclick="OpenDoc()" />
    <menuitem value="Close" onclick="CloseDoc()" />
  </popup>
</menu>

Reference

https://json.org/example.html

Expression Design – tips and tricks

This post will show you how to create graphics using free Microsoft Expression Design 4 tool.

So, we want to crate two kind of graphics:

  • With fixed background color

With transparent background color

First of all, I would like to mention that this tool is for creating vector graphics. Why it is so important? Well, if you create something for instance for 99×99 px and then rescale it to 300×300 px, quality of the graphics would be unchanged.  So lets start.

Case 1: Create the same graphics in different resolution with specific background color

First target is to create two same graphics in png format in different resolutions. We want to create:

  • ApplicationIcon.png which need to be 99×99 pixels (to fit to all WP resolutions)
  • 300×300.png for Catalogue Image on the Windows Phone Store

First we will create new project:

You can use various tools in Expression Design to make your vector graphics or you can import some image (File –> Import Image…) and draw over it. In that case B-Spline would be very helpful tool.

Detailed steps would be:

  • Create main rectangle
  • Draw graphic with Expression Design tools
  • Create slice and set slice properties
  • Export graphics into files

Create main rectangle

First, you need to draw rectangle in full space of the created document 300x300px. Use Rectangle tool and drag rectangle from left upper corner to the right down corner of the document border.

Step 1: Draw rectangle

Step 2: Choose Fill color

Step 3: Choose No Stroke (we don’t need boxed rectangle)

Step 4: Put zero Width for rectangle

Fill color can be any color that you want. Later you can change it to desired color on no color (transparent – more details later).

Draw graphic with Expression Design tools

Now we need to draw some wonderful drawing that represent Windows Phone app. We will draw just one white circle with 15px width in the middle of the blue rectangle (Let your imagination do the rest when creating graphics for you app).

Tips: If you want to align object to another object you need to know that Expression Design use Z-order. So, you can’t do tricks with selecting one object1 (rectangle) first and then object2 (circle) second and hoping that circle would be center aligned with rectangle. The point is that top object would be the main. You need to send circle back (right click on circle and then use Arrange –> Send to Back). Then use Align –> Centers and rearrange order again by sending blue rectangle back.

After using tips recommendation we’ll get final drawing:

Create slice and set slice properties

After we create graphics we need to export it as png or jpg files. So, the next step is to create Slice from the selection. Select full rectangle and use Ctrl+Shift+K or use Object menu and Crate Slice from Selection.

Then we need to set slice properties such as slice name, format and final width and height.

After this, we can use the same procedure to select whole document again, create new slice and set parameters for 300×300 px slice with name 300×300.png.

Export graphics into files

And finally, we need to export slice to png file. For that purpose use Export item from File menu item. Choose desired location and if you have more slices use Export All item in right-down corner.

And that’s it, we just created two png files for our app with blue color as background with two sizes.

Case 2: Use transparent background

But what if you want to create ApplicationIcon for you app and use background color as transparent. So when use different Accent color on your phone background change to that accent color, not fixed blue color as in our first example.

The trick is before creating slice we need to select blue rectangle and set it as Eraser.

Then use standard procedure to create slice with Ctrl+Shift+K and in slice properties set to use Transparent (check box).

And that is all. Export this graphic and you’ll get ApplicationIcon with transparent background.

Remarks: only png file can be transparent, not jpg files.

As a result if we change accent color, our background would change appropriately:

And that is all. Install Microsoft Expression Design 4.0 and be author of graphics for your apps.

Reference

Simple Image cropping in Expression Design

Adding custom shading and highlighting to graphics 

SVG Path and Path Data

Ever wonder, what is SVG path?

A path represents the outline of a shape which can be filled or stroked. A path can also be used as a clipping path, to describe animation, or position text. A path can be used for more than one of these functions at the same time. (See Filling, Stroking and Paint ServersClipping and Masking, Animation (‘animateMotion’), and Text on a Path.)

A path is described using the concept of a current point. In an analogy with drawing on paper, the current point can be thought of as the location of the pen. The position of the pen can be changed, and the outline of a shape (open or closed) can be traced by dragging the pen in either straight lines or curves.

Microsoft Expression Design has a handy feature of Edit->Copy Xml that copies the path data of the shape to clipboard. This data can be used like this;

<!DOCTYPE html>
<html lang="en">
 
<head>
    <title>Expression Web and HTML5</title>
</head>

<body>
    
<svg width="228px" height="253px" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <path
    fill="none"
    stroke="red"
    d="M 10,30
       A 20,20 0,0,1 50,30
       A 20,20 0,0,1 90,30
       Q 90,60 50,90
       Q 10,60 10,30 z" />
</svg>

<svg width="228px" height="253px" viewBox="0 0 228 253">
    <desc>Yellow banana demonstrating path data syntax.</desc>

<g class="banana">
      <path fill="none" stroke="#f7c562" stroke-width="8" stroke-linecap="round" stroke-linejoin="round" d="    M8.64,223.948c0,0,143.468,3.431,185.777-181.808c2.673-11.702-1.23-20.154,1.316-33.146h16.287c0,0-3.14,17.248,1.095,30.848
      c21.392,68.692-4.179,242.343-204.227,196.59L8.64,223.948z" />
      <path fill="none" stroke="#f7c562" stroke-width="8" stroke-linecap="round" stroke-linejoin="round" d="    M8.767,230.326c0,0,188.246,40.154,196.485-160.139" />
    </g>
  </svg>

</body>

</html>

Here is the output;

Amazing…

Reference

https://www.w3.org/TR/SVG2/paths.html

https://www.codeproject.com/Articles/237451/Using-the-Copy-XAML-Feature-in-Expression-Design-t

https://www.sitepoint.com/closer-look-svg-path-data/

Bootstrap Multiselect

Bootstrap Multiselect is a JQuery based plugin to provide an intuitive user interface for using select inputs with the multiple attribute present. Instead of a select a bootstrap button will be shown w dropdown menu containing the single options as checkboxes.

Read more by clicking on below link;

https://davidstutz.github.io/bootstrap-multiselect/

Here is the Git repo for download