Tuesday, May 30, 2017

Bootstrap for ASP 01

Start a new web site, asp.net empty website.

Create a new blank page, Bootstrap01.aspx

Add a reference to jquery:
tools, nuget, install jquery

Add a reference to Bootstrap using cdn:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Bootstrap01.aspx.cs" Inherits="Bootstrap01" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Bootstrap01</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

</head>
<body>
    
    <form id="form1" runat="server">
    <div>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
    </div>
    </form>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>
</html>

Note that bootstrap requires jquery and both the .css and .js files to work properly.


d

Tuesday, May 2, 2017

JSON to C# dataset

The following will deserialize a Canvas json response into a dataset

using System;
using System.Data;
using System.Windows.Forms;
using Newtonsoft.Json;
using System.Xml;

        private void temp2()
        {
            string pjson = System.IO.File.ReadAllText(@"c:\temp\json.txt");

            DataSet dsRecognize = new DataSet();
           
            XmlDocument xdRecognize = new XmlDocument();
            xdRecognize = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"Row\":" + pjson + "}", "root");

            dsRecognize.ReadXml(new XmlNodeReader(xdRecognize));

            dataGridView1.DataSource = dsRecognize.Tables[0];

        }
**************************
Some notes:
c:\temp\json.txt is a copy of a json response. Remove the initial "while(1);" but keep the brackets "[]"

I sent the first table to a dataset, and it seemed to be good data.