ASP.NET Podcast

ASP.NET Podcast is geared towards the Microsoft .NET Framework and ASP.NET.
The podcast is run by Wally McClure, David Penton, and Paul Glavich.
Welcome to ASP.NET Podcast Sign in | Join | Help
in Search

ASP.NET Podcast

The ASP.NET Podcast features, technical talks, interviews, news, reviews, and Wallyisms. Wallace B. (Wally) McClure, David Penton, and Paul Glavich are your hosts. We talk about ASP.NET, AJAX, Performance, Databases, WCF, Silverlight, Cloud Computing, Windows Azure, and whatever else we decide to talk about.

  • ASP.NET Podcast Show #149 - MonoDroid Development on the Apple Macintosh OSX

    Given that I have a cast on my arm, I installed the MonoDroid Development Framework for Apple Macs today.  I walked through it and found that things are pretty much the same as with the MonoDroid plugin for Visual Studio 2010.  This post shows the video displaying this.  This video is based on MonoDroid Preview 11.1.

    Subscribe to everything.

    Subscribe to WMV.

    Subscribe to M4V for iPhone/iPad.

    Subscribe to MP3.

    Download WMV.

    Download M4V.

    Download MP4.

    Download MP3.

  • ASP.NET Podcast Show #148 - ASP.NET WebForms to build a Mobile Web Application

    This is the video and source code for an ASP.NET WebForms app that I wrote that is optimized for the iPhone and mobile environments. 

    Part 1:

    Part 2:

    Part 3:

    Subscribe to everything.

    Subscribe to WMV.

    Subscribe to M4V for iPhone/iPad.

    Subscribe to MP3.

    Download WMV.

    Download M4V for iPhone/iPad.

    Download MP3.

    Link to iWebKit.

    Source Code:

    <%@ Page Title="MapSplore" Language="C#" MasterPageFile="iPhoneMaster.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="AT_iPhone_Default" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="Content" Runat="Server" ClientIDMode="Static">
        <asp:ScriptManager ID="sm" runat="server"
            EnablePartialRendering="true" EnableHistory="false" EnableCdn="true" />
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
        <script  language="javascript"  type="text/javascript">
        <!--
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandle);
        function endRequestHandle(sender, Args) {
            setupMapDiv();
            setupPlaceIveBeen();
        }
        function setupPlaceIveBeen() {
            var mapPlaceIveBeen = document.getElementById('divPlaceIveBeen');
            if (mapPlaceIveBeen != null) {
                var PlaceLat = document.getElementById('<%=hdPlaceIveBeenLatitude.ClientID %>').value;
                var PlaceLon = document.getElementById('<%=hdPlaceIveBeenLongitude.ClientID %>').value;
                var PlaceTitle = document.getElementById('<%=lblPlaceIveBeenName.ClientID %>').innerHTML;
                var latlng = new google.maps.LatLng(PlaceLat, PlaceLon);
                var myOptions = {
                    zoom: 14,
                    center: latlng,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
                var map = new google.maps.Map(mapPlaceIveBeen, myOptions);
                var marker = new google.maps.Marker({
                    position: new google.maps.LatLng(PlaceLat, PlaceLon),
                    map: map,
                    title: PlaceTitle,
                    clickable: false
                });
            }
        }
        function setupMapDiv() {
            var mapdiv = document.getElementById('divImHere');
            if (mapdiv != null) {
                var PlaceLat = document.getElementById('<%=hdPlaceLat.ClientID %>').value;
                var PlaceLon = document.getElementById('<%=hdPlaceLon.ClientID %>').value;
                var PlaceTitle = document.getElementById('<%=hdPlaceTitle.ClientID %>').value;
                var latlng = new google.maps.LatLng(PlaceLat, PlaceLon);
                var myOptions = {
                    zoom: 14,
                    center: latlng,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
                var map = new google.maps.Map(mapdiv, myOptions);
                var marker = new google.maps.Marker({
                    position: new google.maps.LatLng(PlaceLat, PlaceLon),
                    map: map,
                    title: PlaceTitle,
                    clickable: false
                });
            }

        }
        -->
        </script>
        <asp:HiddenField ID="Latitude" runat="server" />
        <asp:HiddenField ID="Longitude" runat="server" />
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js%22%3E%3C/script>
        <script language="javascript" type="text/javascript">
            $(document).ready(function () {
                GetLocation();
                setupMapDiv();
                setupPlaceIveBeen();
            });
            function GetLocation() {
                if (navigator.geolocation != null) {
                    navigator.geolocation.getCurrentPosition(getData);
                }
                else {
                    var mess = document.getElementById('<%=Message.ClientID %>');
                    mess.innerHTML = "Sorry, your browser does not support geolocation. " +
                        "Try the latest version of Safari on the iPhone, Android browser, or the latest version of FireFox.";
                }
            }
            function UpdateLocation_Click() {
                GetLocation();
            }
            function getData(position) {
                var latitude = position.coords.latitude;
                var longitude = position.coords.longitude;
                var hdLat = document.getElementById('<%=Latitude.ClientID %>');
                var hdLon = document.getElementById('<%=Longitude.ClientID %>');
                hdLat.value = latitude;
                hdLon.value = longitude;
            }
        </script>
        <asp:Label ID="Message" runat="server" />
        <asp:UpdatePanel ID="upl" runat="server">
            <ContentTemplate>
        <asp:Panel ID="pnlStart" runat="server" Visible="true">
        <div id="topbar">
            <div id="title">MapSplore</div>
        </div>
        <div id="content">
            <ul class="pageitem">
                <li class="menu">
                    <asp:LinkButton ID="lbLocalDeals" runat="server" onclick="lbLocalDeals_Click">
                    <asp:Image ID="imLocalDeals" runat="server" ImageUrl="~/Images/ArtFavor_Money_Bag_Icon.png" Height="30" />
                    <span class="name">Local Deals.</span>
                    <span class="arrow"></span>
                    </asp:LinkButton>
                    </li>
                <li class="menu">
                    <asp:LinkButton ID="lbLocalPlaces" runat="server" onclick="lbLocalPlaces_Click">
                    <asp:Image ID="imLocalPlaces" runat="server" ImageUrl="~/Images/Andy_Houses_on_the_horizon_-_Starburst_remix.png" Height="30" />
                    <span class="name">Local Places.</span>
                    <span class="arrow"></span>
                    </asp:LinkButton>
                    </li>
                <li class="menu">
                    <asp:LinkButton ID="lbWhereIveBeen" runat="server" onclick="lbWhereIveBeen_Click">
                    <asp:Image ID="imImHere" runat="server" ImageUrl="~/Images/ryanlerch_flagpole.png" Height="30" />
                    <span class="name">I've been here.</span>
                    <span class="arrow"></span>
                    </asp:LinkButton>
                    </li>
                <li class="menu">
                    <asp:LinkButton ID="lbMyStats" runat="server">
                    <asp:Image ID="imMyStats" runat="server" ImageUrl="~/Images/Anonymous_Spreadsheet.png" Height="30" />
                    <span class="name">My Stats.</span>
                    <span class="arrow"></span>
                    </asp:LinkButton>
                    </li>
                <li class="menu">
                    <asp:LinkButton ID="lbAddAPlace" runat="server" onclick="lbAddAPlace_Click">
                    <asp:Image ID="imAddAPlace" runat="server" ImageUrl="~/Images/jean_victor_balin_add.png" Height="30" />
                    <span class="name">Add a Place.</span>
                    <span class="arrow"></span>
                    </asp:LinkButton>
                    </li>
                <li class="button">
                    <input type="button" value="Update Your Current Location" onclick="UpdateLocation_Click()">
                    </li>
            </ul>
        </div>
        </asp:Panel>
        <div>
        <asp:Panel ID="pnlCoupons" runat="server" Visible="false">
            <div id="topbar">
            <div id="title">MapSplore</div>
            <div id="leftbutton">
                <asp:LinkButton runat="server" Text="Return"
                    ID="ReturnFromDeals" OnClick="ReturnFromDeals_Click" /></div></div>
        <div class="content">
        <asp:ListView ID="lvCoupons" runat="server">
            <LayoutTemplate>
                <ul class="pageitem" runat="server">
                    <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
                </ul>
            </LayoutTemplate>
            <ItemTemplate>
                <li class="menu">
                    <asp:LinkButton ID="lbBusiness" runat="server" Text='<%#Eval("Place.Name") %>' OnClick="lbBusiness_Click">
                        <span class="comment">
                        <asp:Label ID="lblAddress" runat="server" Text='<%#Eval("Place.Address1") %>' />
                        <asp:Label ID="lblDis" runat="server" Text='<%# Convert.ToString(Convert.ToInt32(Eval("Place.Distance"))) + " meters" %>' CssClass="smallText" />
                        <asp:HiddenField ID="hdPlaceId" runat="server" Value='<%#Eval("PlaceId") %>' />
                        <asp:HiddenField ID="hdGeoPromotionId" runat="server" Value='<%#Eval("GeoPromotionId") %>' />
                        </span>
                        <span class="arrow"></span>
                    </asp:LinkButton></li></ItemTemplate></asp:ListView><asp:GridView ID="gvCoupons" runat="server" AutoGenerateColumns="false">
                <HeaderStyle BackColor="Silver" />
                <AlternatingRowStyle BackColor="Wheat" />
                <Columns>
                    <asp:TemplateField AccessibleHeaderText="Business" HeaderText="Business">
                        <ItemTemplate>
                            <asp:Image ID="imPlaceType" runat="server" Text='<%#Eval("Type") %>' ImageUrl='<%#Eval("Image") %>' />
                            <asp:LinkButton ID="lbBusiness" runat="server" Text='<%#Eval("Name") %>' OnClick="lbBusiness_Click" />
                            <asp:LinkButton ID="lblAddress" runat="server" Text='<%#Eval("Address1") %>' CssClass="smallText" />
                            <asp:Label ID="lblDis" runat="server" Text='<%# Convert.ToString(Convert.ToInt32(Eval("Distance"))) + " meters" %>' CssClass="smallText" />
                            <asp:HiddenField ID="hdPlaceId" runat="server" Value='<%#Eval("PlaceId") %>' />
                            <asp:HiddenField ID="hdGeoPromotionId" runat="server" Value='<%#Eval("GeoPromotionId") %>' />
                            <asp:Label ID="lblInfo" runat="server" Visible="false" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </div>
        </asp:Panel>
        <asp:Panel ID="pnlPlaces" runat="server" Visible="false">
        <div id="topbar">
            <div id="title">
                MapSplore</div><div id="leftbutton">
                <asp:LinkButton runat="server" Text="Return"
                    ID="ReturnFromPlaces" OnClick="ReturnFromPlaces_Click" /></div></div>
            <div id="content">
            <asp:ListView ID="lvPlaces" runat="server">
                <LayoutTemplate>
                    <ul id="ulPlaces" class="pageitem" runat="server">
                        <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
                        <li class="menu">
                            <asp:LinkButton ID="lbNotListed" runat="server" CssClass="name"
                                OnClick="lbNotListed_Click">
                                Place not listed
                                <span class="arrow"></span>   
                            </asp:LinkButton>
                        </li>
                    </ul>
                </LayoutTemplate>
                <ItemTemplate>
                <li class="menu">
                    <asp:LinkButton ID="lbImHere" runat="server" CssClass="name"
                        OnClick="lbImHere_Click">
                    <%#DisplayName(Eval("Name")) %>&nbsp;
                    <%# Convert.ToString(Convert.ToInt32(Eval("Distance"))) + " meters" %>
                    <asp:HiddenField ID="hdPlaceId" runat="server" Value='<%#Eval("PlaceId") %>' />
                    <span class="arrow"></span>
                    </asp:LinkButton></li></ItemTemplate></asp:ListView>
        </div>
        </asp:Panel>
        <asp:Panel ID="pnlImHereNow" runat="server" Visible="false">
            <div id="topbar">
            <div id="title">
                MapSplore</div><div id="leftbutton">
                <asp:LinkButton runat="server" Text="Places"
                    ID="lbImHereNowReturn" OnClick="lbImHereNowReturn_Click" /></div></div>
                <div id="rightbutton">
                <asp:LinkButton runat="server" Text="Beginning"
                    ID="lbBackToBeginning" OnClick="lbBackToBeginning_Click" />
                </div>
            <div id="content">
            <ul class="pageitem">
            <asp:HiddenField ID="hdPlaceId" runat="server" />
            <asp:HiddenField ID="hdPlaceLat" runat="server" />
            <asp:HiddenField ID="hdPlaceLon" runat="server" />
            <asp:HiddenField ID="hdPlaceTitle" runat="server" />
            <asp:Button ID="btnImHereNow" runat="server"
                Text="I'm here" OnClick="btnImHereNow_Click" />
                <asp:Label ID="lblPlaceTitle" runat="server" /><br />
            <asp:TextBox ID="txtWhatsHappening" runat="server" TextMode="MultiLine" Rows="2" style="width:300px" /><br />
            <div id="divImHere" style="width:300px; height:300px"></div>
            </div>
            </ul>
        </asp:Panel>
        <asp:Panel runat="server" ID="pnlIveBeenHere" Visible="false">
            <div id="topbar">
            <div id="title">
                Where I've been</div><div id="leftbutton">
                <asp:LinkButton ID="lbIveBeenHereBack" runat="server" Text="Back" OnClick="lbIveBeenHereBack_Click" /></div></div>
            <div id="content">
            <asp:ListView ID="lvWhereIveBeen" runat="server">
                <LayoutTemplate>
                    <ul id="ulWhereIveBeen" class="pageitem" runat="server">
                        <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
                    </ul>
                </LayoutTemplate>
                <ItemTemplate>
                <li class="menu" runat="server">
                    <asp:LinkButton ID="lbPlaceIveBeen" runat="server" OnClick="lbPlaceIveBeen_Click" CssClass="name">
                        <asp:Label ID="lblPlace" runat="server" Text='<%#Eval("PlaceName") %>' /> at
                        <asp:Label ID="lblTime" runat="server" Text='<%#Eval("ATTime") %>' CssClass="content" />
                        <asp:HiddenField ID="hdATID" runat="server" Value='<%#Eval("ATID") %>' />
                        <span class="arrow"></span>
                    </asp:LinkButton>
                </li>
                </ItemTemplate>
            </asp:ListView>
            </div>
            </asp:Panel>
        <asp:Panel runat="server" ID="pnlPlaceIveBeen" Visible="false">
            <div id="topbar">
            <div id="title">
                I've been here
            </div>
            <div id="leftbutton">
                <asp:LinkButton ID="lbPlaceIveBeenBack" runat="server" Text="Back" OnClick="lbPlaceIveBeenBack_Click" />
            </div>
            <div id="rightbutton">
                <asp:LinkButton ID="lbPlaceIveBeenBeginning" runat="server" Text="Beginning" OnClick="lbPlaceIveBeenBeginning_Click" />
            </div>
            </div>
            <div id="content">
                <ul class="pageitem">
                <li>
                <asp:HiddenField ID="hdPlaceIveBeenPlaceId" runat="server" />
                <asp:HiddenField ID="hdPlaceIveBeenLatitude" runat="server" />
                <asp:HiddenField ID="hdPlaceIveBeenLongitude" runat="server" />
                <asp:Label ID="lblPlaceIveBeenName" runat="server" /><br />
                <asp:Label ID="lblPlaceIveBeenAddress" runat="server" /><br />
                <asp:Label ID="lblPlaceIveBeenCity" runat="server" />,
                <asp:Label ID="lblPlaceIveBeenState" runat="server" />
                <asp:Label ID="lblPlaceIveBeenZipCode" runat="server" /><br />
                <asp:Label ID="lblPlaceIveBeenCountry" runat="server" /><br />
                <div id="divPlaceIveBeen" style="width:300px; height:300px"></div>
                </li>
                </ul>
            </div>
               
        </asp:Panel>

            <asp:Panel ID="pnlAddPlace" runat="server" Visible="false">
                    <div id="topbar">
    <div id="title">MapSplore</div><div id="leftbutton">
    <asp:LinkButton ID="lbAddPlaceReturn" runat="server" Text="Back" OnClick="lbAddPlaceReturn_Click" /></div><div id="rightnav">
    </div>
    </div>
    <div id="content">
        <ul class="pageitem">
            <li id="liPlaceAddMessage" runat="server" visible="false">
            <asp:Label ID="PlaceAddMessage" runat="server" />
            </li>
            <li class="bigfield">
            <asp:TextBox ID="txtPlaceName" runat="server" placeholder="Name of Establishment" />
            </li>
            <li class="bigfield">
            <asp:TextBox ID="txtAddress1" runat="server" placeholder="Address 1" />
            </li>
            <li class="bigfield">
            <asp:TextBox ID="txtCity" runat="server" placeholder="City" />
            </li>
            <li class="select">
            <asp:DropDownList ID="ddlProvince" runat="server" placeholder="Select State" /> 
            <span class="arrow"></span>     
            </li>
            <li class="bigfield">
            <asp:TextBox ID="txtZipCode" runat="server" placeholder="Zip Code" />
            </li>
            <li class="select">
            <asp:DropDownList ID="ddlCountry" runat="server"
                onselectedindexchanged="ddlCountry_SelectedIndexChanged" />
            <span class="arrow"></span>
            </li>
            <li class="bigfield">
            <asp:TextBox ID="txtPhoneNumber" runat="server" placeholder="Phone Number" />
            </li>
            <li class="checkbox">
                <span class="name">You Here Now:</span> <asp:CheckBox ID="cbYouHereNow" runat="server" Checked="true" />
            </li>
            <li class="button">
            <asp:Button ID="btnAdd" runat="server" Text="Add Place"
                onclick="btnAdd_Click" />
            </li>
        </ul>
    </div>
            </asp:Panel>
            <asp:Panel ID="pnlImHere" runat="server" Visible="false">
                <asp:TextBox ID="txtImHere" runat="server"
                    TextMode="MultiLine" Rows="3" Columns="40" /><br />
                <asp:DropDownList ID="ddlPlace" runat="server" /><br />
                <asp:Button ID="btnHere" runat="server" Text="Tell Everyone I'm Here"
                    onclick="btnHere_Click" /><br />
            </asp:Panel>

        </div>
        </ContentTemplate>
        </asp:UpdatePanel>

    </asp:Content>

    Code Behind .cs file:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using LocationDataModel;

    public partial class AT_iPhone_Default : ViewStatePage
    {
        private iPhoneDevice ipd;

        protected void Page_Load(object sender, EventArgs e)
        {
            LocationDataEntities lde = new LocationDataEntities();
            if (!Page.IsPostBack)
            {
                var Countries = from c in lde.Countries select c;
                foreach (Country co in Countries)
                {
                    ddlCountry.Items.Add(new ListItem(co.Name, co.CountryId.ToString()));
                }
                ddlCountry_SelectedIndexChanged(ddlCountry, null);
                if (AppleIPhone.IsIPad())
                    ipd = iPhoneDevice.iPad;
                if (AppleIPhone.IsIPhone())
                    ipd = iPhoneDevice.iPhone;
                if (AppleIPhone.IsIPodTouch())
                    ipd = iPhoneDevice.iPodTouch;
            }
        }
        protected void btnPlaces_Click(object sender, EventArgs e)
        {
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            bool blImHere = cbYouHereNow.Checked;
            string Place = txtPlaceName.Text,
                Address1 = txtAddress1.Text,
                City = txtCity.Text,
                ZipCode = txtZipCode.Text,
                PhoneNumber = txtPhoneNumber.Text,
                ProvinceId = ddlProvince.SelectedItem.Value,
                CountryId = ddlCountry.SelectedItem.Value;
            int iProvinceId, iCountryId;
            double dLatitude, dLongitude;
            DataAccess da = new DataAccess();
            if ((!String.IsNullOrEmpty(ProvinceId)) &&
                (!String.IsNullOrEmpty(CountryId)))
            {
                iProvinceId = Convert.ToInt32(ProvinceId);
                iCountryId = Convert.ToInt32(CountryId);
                if (blImHere)
                {
                    dLatitude = Convert.ToDouble(Latitude.Value);
                    dLongitude = Convert.ToDouble(Longitude.Value);
                    da.StorePlace(Place, Address1, String.Empty, City,
                        iProvinceId, ZipCode, iCountryId, PhoneNumber,
                        dLatitude, dLongitude);
                }
                else
                {
                    da.StorePlace(Place, Address1, String.Empty, City,
                        iProvinceId, ZipCode, iCountryId, PhoneNumber);
                }
                liPlaceAddMessage.Visible = true;
                PlaceAddMessage.Text = "Awesome, your place has been added. Add Another!";
                txtPlaceName.Text = String.Empty;
                txtAddress1.Text = String.Empty;
                txtCity.Text = String.Empty;
                ddlProvince.SelectedIndex = -1;
                txtZipCode.Text = String.Empty;
                txtPhoneNumber.Text = String.Empty;
            }
            else
            {
                liPlaceAddMessage.Visible = true;
                PlaceAddMessage.Text = "Please select a State and a Country.";
            }
        }
        protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
        {
            string CountryId = ddlCountry.SelectedItem.Value;
            if (!String.IsNullOrEmpty(CountryId))
            {
                int iCountryId = Convert.ToInt32(CountryId);
                LocationDataModel.LocationDataEntities lde = new LocationDataModel.LocationDataEntities();
                var prov = from p in lde.Provinces where p.CountryId == iCountryId
                           orderby p.ProvinceName select p;
               
                ddlProvince.Items.Add(String.Empty);
                foreach (Province pr in prov)
                {
                    ddlProvince.Items.Add(new ListItem(pr.ProvinceName, pr.ProvinceId.ToString()));
                }
            }
            else
            {
                ddlProvince.Items.Clear();
            }
        }
        protected void btnImHere_Click(object sender, EventArgs e)
        {
            int i = 0;
            DataAccess da = new DataAccess();
            double Lat = Convert.ToDouble(Latitude.Value),
                Lon = Convert.ToDouble(Longitude.Value);
            List<Place> lp = da.NearByLocations(Lat, Lon);
            foreach (Place p in lp)
            {
                ListItem li = new ListItem(p.Name, p.PlaceId.ToString());
                if (i == 0)
                {
                    li.Selected = true;
                }
                ddlPlace.Items.Add(li);
                i++;
            }
            pnlAddPlace.Visible = false;
            pnlImHere.Visible = true;
        }
        protected void lbImHere_Click(object sender, EventArgs e)
        {
            string UserName = Membership.GetUser().UserName;
            ListViewItem lvi = (ListViewItem)(((LinkButton)sender).Parent);
            HiddenField hd = (HiddenField)lvi.FindControl("hdPlaceId");
            long PlaceId = Convert.ToInt64(hd.Value);
            double dLatitude = Convert.ToDouble(Latitude.Value);
            double dLongitude = Convert.ToDouble(Longitude.Value);
            DataAccess da = new DataAccess();
            Place pl = da.GetPlace(PlaceId);
            pnlImHereNow.Visible = true;
            pnlPlaces.Visible = false;
            hdPlaceId.Value = PlaceId.ToString();
            hdPlaceLat.Value = pl.Latitude.ToString();
            hdPlaceLon.Value = pl.Longitude.ToString();
            hdPlaceTitle.Value = pl.Name;
            lblPlaceTitle.Text = pl.Name;
        }
        protected void btnHere_Click(object sender, EventArgs e)
        {
            string UserName = Membership.GetUser().UserName;
            string WhatsH = txtImHere.Text;
            long PlaceId = Convert.ToInt64(ddlPlace.SelectedValue);
            double dLatitude = Convert.ToDouble(Latitude.Value);
            double dLongitude = Convert.ToDouble(Longitude.Value);
            DataAccess da = new DataAccess();
            da.StoreUserAT(UserName, PlaceId, WhatsH,
                dLatitude, dLongitude);
        }
        protected void btnLocalCoupons_Click(object sender, EventArgs e)
        {
            double dLatitude = Convert.ToDouble(Latitude.Value);
            double dLongitude = Convert.ToDouble(Longitude.Value);
            DataAccess da = new DataAccess();

        }
        protected void lbBusiness_Click(object sender, EventArgs e)
        {
            string UserName = Membership.GetUser().UserName;
            GridViewRow gvr = (GridViewRow)(((LinkButton)sender).Parent.Parent);
            HiddenField hd = (HiddenField)gvr.FindControl("hdPlaceId");
            string sPlaceId = hd.Value;
            Int64 PlaceId;
            if (!String.IsNullOrEmpty(sPlaceId))
            {
                PlaceId = Convert.ToInt64(sPlaceId);
            }
        }
        protected void lbLocalDeals_Click(object sender, EventArgs e)
        {
            double dLatitude = Convert.ToDouble(Latitude.Value);
            double dLongitude = Convert.ToDouble(Longitude.Value);
            DataAccess da = new DataAccess();
            pnlCoupons.Visible = true;
            pnlStart.Visible = false;
            List<GeoPromotion> lgp = da.NearByDeals(dLatitude, dLongitude);
            lvCoupons.DataSource = lgp;
            lvCoupons.DataBind();
        }
        protected void lbLocalPlaces_Click(object sender, EventArgs e)
        {
            DataAccess da = new DataAccess();
            double Lat = Convert.ToDouble(Latitude.Value);
            double Lon = Convert.ToDouble(Longitude.Value);
            List<LocationDataModel.Place> places = da.NearByLocations(Lat, Lon);
            lvPlaces.DataSource = places;
            lvPlaces.SelectedIndex = -1;
            lvPlaces.DataBind();
            pnlPlaces.Visible = true;
            pnlStart.Visible = false;
        }
        protected void ReturnFromPlaces_Click(object sender, EventArgs e)
        {
            pnlPlaces.Visible = false;
            pnlStart.Visible = true;
        }
        protected void ReturnFromDeals_Click(object sender, EventArgs e)
        {
            pnlCoupons.Visible = false;
            pnlStart.Visible = true;
        }
        protected void btnImHereNow_Click(object sender, EventArgs e)
        {
            long PlaceId = Convert.ToInt32(hdPlaceId.Value);
            string UserName = Membership.GetUser().UserName;
            string WhatsHappening = txtWhatsHappening.Text;
            double UserLat = Convert.ToDouble(Latitude.Value);
            double UserLon = Convert.ToDouble(Longitude.Value);
            DataAccess da = new DataAccess();
            da.StoreUserAT(UserName, PlaceId, WhatsHappening,
                UserLat, UserLon);
        }
        protected void lbImHereNowReturn_Click(object sender, EventArgs e)
        {
            pnlImHereNow.Visible = false;
            pnlPlaces.Visible = true;
        }
        protected void lbBackToBeginning_Click(object sender, EventArgs e)
        {
            pnlStart.Visible = true;
            pnlImHereNow.Visible = false;
        }
        protected void lbWhereIveBeen_Click(object sender, EventArgs e)
        {
            string UserName = Membership.GetUser().UserName;
            pnlStart.Visible = false;
            pnlIveBeenHere.Visible = true;
            DataAccess da = new DataAccess();
            lvWhereIveBeen.DataSource = da.UserATs(UserName, 0, 15);
            lvWhereIveBeen.DataBind();
        }
        protected void lbIveBeenHereBack_Click(object sender, EventArgs e)
        {
            pnlIveBeenHere.Visible = false;
            pnlStart.Visible = true;
        }

        protected void lbPlaceIveBeen_Click(object sender, EventArgs e)
        {
            LinkButton lb = (LinkButton)sender;
            ListViewItem lvi = (ListViewItem)lb.Parent.Parent;
            HiddenField hdATID = (HiddenField)lvi.FindControl("hdATID");
            Int64 ATID = Convert.ToInt64(hdATID.Value);
            DataAccess da = new DataAccess();
            pnlIveBeenHere.Visible = false;
            pnlPlaceIveBeen.Visible = true;
            var plac = da.GetPlaceViaATID(ATID);
            hdPlaceIveBeenPlaceId.Value = plac.PlaceId.ToString();
            hdPlaceIveBeenLatitude.Value = plac.Latitude.ToString();
            hdPlaceIveBeenLongitude.Value = plac.Longitude.ToString();
            lblPlaceIveBeenName.Text = plac.Name;
            lblPlaceIveBeenAddress.Text = plac.Address1;
            lblPlaceIveBeenCity.Text = plac.City;
            lblPlaceIveBeenState.Text = plac.Province.ProvinceName;
            lblPlaceIveBeenZipCode.Text = plac.ZipCode;
            lblPlaceIveBeenCountry.Text = plac.Country.Name;
        }

        protected void lbNotListed_Click(object sender, EventArgs e)
        {
            SetupAddPoint();
            pnlPlaces.Visible = false;
        }

        protected void lbAddAPlace_Click(object sender, EventArgs e)
        {
            SetupAddPoint();
        }

        private void SetupAddPoint()
        {
            double lat = Convert.ToDouble(Latitude.Value);
            double lon = Convert.ToDouble(Longitude.Value);
            DataAccess da = new DataAccess();
            var zip = da.WhereAmIAt(lat, lon);
            if (zip.Count > 0)
            {
                var z0 = zip[0];
                txtCity.Text = z0.City;
                txtZipCode.Text = z0.ZipCode;
                ddlProvince.ClearSelection();
                if (z0.ProvinceId.HasValue == true)
                {
                    foreach (ListItem li in ddlProvince.Items)
                    {
                        if (li.Value == z0.ProvinceId.Value.ToString())
                        {
                            li.Selected = true;
                            break;
                        }
                    }
                }
            }
            pnlAddPlace.Visible = true;
            pnlStart.Visible = false;
        }
        protected void lbAddPlaceReturn_Click(object sender, EventArgs e)
        {
            pnlAddPlace.Visible = false;
            pnlStart.Visible = true;
            liPlaceAddMessage.Visible = false;
            PlaceAddMessage.Text = String.Empty;
        }
        protected void lbPlaceIveBeenBack_Click(object sender, EventArgs e)
        {
            pnlIveBeenHere.Visible = true;
            pnlPlaceIveBeen.Visible = false;
           
        }
        protected void lbPlaceIveBeenBeginning_Click(object sender, EventArgs e)
        {
            pnlPlaceIveBeen.Visible = false;
            pnlStart.Visible = true;
        }
        protected string DisplayName(object val)
        {
            string strVal = Convert.ToString(val);

            if (AppleIPhone.IsIPad())
            {
                ipd = iPhoneDevice.iPad;
            }
            if (AppleIPhone.IsIPhone())
            {
                ipd = iPhoneDevice.iPhone;
            }
            if (AppleIPhone.IsIPodTouch())
            {
                ipd = iPhoneDevice.iPodTouch;
            }
            return (iPhoneHelper.DisplayContentOnMenu(strVal, ipd));
        }
    }

    iPhoneHelper.cs file:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    public enum iPhoneDevice
    {
        iPhone, iPodTouch, iPad
    }
    /// <summary>
    /// Summary description for iPhoneHelper
    /// </summary>
    ///
    public class iPhoneHelper
    {
     public iPhoneHelper()
     {
      //
      // TODO: Add constructor logic here
      //
     }

    // This code is stupid in retrospect. Use css to solve this problem 

        public static string DisplayContentOnMenu(string val, iPhoneDevice ipd)
        {
            string Return = val;
            string Elipsis = "...";
            int iPadMaxLength = 30;
            int iPhoneMaxLength = 15;
            if (ipd == iPhoneDevice.iPad)
            {
                if (Return.Length > iPadMaxLength)
                {
                    Return = Return.Substring(0, iPadMaxLength - Elipsis.Length) + Elipsis;
                }
            }
            else
            {
                if (Return.Length > iPhoneMaxLength)
                {
                    Return = Return.Substring(0, iPhoneMaxLength - Elipsis.Length) + Elipsis;
                }
            }
            return (Return);
        }

    Source code for the ViewStatePage:

    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    /// <summary>
    /// Summary description for BasePage
    /// </summary>
    #region Base class for a page.
    public class ViewStatePage : System.Web.UI.Page
    {

        PageStatePersisterToDatabase myPageStatePersister;
       
        public ViewStatePage()
            : base()
        {
            myPageStatePersister = new PageStatePersisterToDatabase(this);
        }

        protected override PageStatePersister PageStatePersister
        {
            get
            {
                return myPageStatePersister;
            }
        }

    }
    #endregion

    #region This class will override the page persistence to store page state in a database.
    public class PageStatePersisterToDatabase : PageStatePersister
    {
        private string ViewStateKeyField = "__VIEWSTATE_KEY";
        private string _exNoConnectionStringFound = "No Database Configuration information is in the web.config.";

        public PageStatePersisterToDatabase(Page page)
            : base(page)
        {
        }

        public override void Load()
        {

            // Get the cache key from the web form data
            System.Int64 key = Convert.ToInt64(Page.Request.Params[ViewStateKeyField]);

            Pair state = this.LoadState(key);

            // Abort if cache object is not of type Pair
            if (state == null)
                throw new ApplicationException("Missing valid " + ViewStateKeyField);

            // Set view state and control state
            ViewState = state.First;
            ControlState = state.Second;
        }

        public override void Save()
        {

            // No processing needed if no states available
            if (ViewState == null && ControlState != null)
                return;

            System.Int64 key;
            IStateFormatter formatter = this.StateFormatter;
            Pair statePair = new Pair(ViewState, ControlState);

            // Serialize the statePair object to a string.
            string serializedState = formatter.Serialize(statePair);

            // Save the ViewState and get a unique identifier back.
            key = SaveState(serializedState);

            // Register hidden field to store cache key in
            // Page.ClientScript does not work properly with Atlas.
            //Page.ClientScript.RegisterHiddenField(ViewStateKeyField, key.ToString());
            ScriptManager.RegisterHiddenField(this.Page, ViewStateKeyField, key.ToString());
        }

        private System.Int64 SaveState(string PageState)
        {
            System.Int64 i64Key = 0;
            string strConn = String.Empty,
                strProvider = String.Empty;

            string strSql = "insert into tblPageState ( SerializedState ) values ( '" + SqlEscape(PageState) + "');select scope_identity();";
            SqlConnection sqlCn;
            SqlCommand sqlCm;
            try
            {
                GetDBConnectionString(ref strConn, ref strProvider);
                sqlCn = new SqlConnection(strConn);
                sqlCm = new SqlCommand(strSql, sqlCn);
                sqlCn.Open();
                i64Key = Convert.ToInt64(sqlCm.ExecuteScalar());
                if (sqlCn.State != ConnectionState.Closed)
                {
                    sqlCn.Close();
                }
                sqlCn.Dispose();
                sqlCm.Dispose();
            }
            finally
            {
                sqlCn = null;
                sqlCm = null;
            }
            return i64Key;
        }

        private Pair LoadState(System.Int64 iKey)
        {
            string strConn = String.Empty,
                strProvider = String.Empty,
                SerializedState = String.Empty,
                strMinutesInPast = GetMinutesInPastToDelete();
            Pair PageState;
            string strSql = "select SerializedState from tblPageState where tblPageStateID=" + iKey.ToString() + ";" +
                "delete from tblPageState where DateUpdated<DateAdd(mi, " + strMinutesInPast + ", getdate());";
            SqlConnection sqlCn;
            SqlCommand sqlCm;
            try
            {
                GetDBConnectionString(ref strConn, ref strProvider);
                sqlCn = new SqlConnection(strConn);
                sqlCm = new SqlCommand(strSql, sqlCn);

                sqlCn.Open();
                SerializedState = Convert.ToString(sqlCm.ExecuteScalar());
                IStateFormatter formatter = this.StateFormatter;

                if ((null == SerializedState) ||
                    (String.Empty == SerializedState))
                {
                    throw (new ApplicationException("No ViewState records were returned."));
                }

                // Deserilize returns the Pair object that is serialized in
                // the Save method.
                PageState = (Pair)formatter.Deserialize(SerializedState);

                if (sqlCn.State != ConnectionState.Closed)
                {
                    sqlCn.Close();
                }
                sqlCn.Dispose();
                sqlCm.Dispose();
            }
            finally
            {
                sqlCn = null;
                sqlCm = null;
            }
            return PageState;
        }

        private string SqlEscape(string Val)
        {
            string ReturnVal = String.Empty;
            if (null != Val)
            {
                ReturnVal = Val.Replace("'", "''");
            }
            return (ReturnVal);
        }
        private void GetDBConnectionString(ref string ConnectionStringValue, ref string ProviderNameValue)
        {
            if (System.Configuration.ConfigurationManager.ConnectionStrings.Count > 0)
            {
                ConnectionStringValue = System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
                ProviderNameValue = System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationServices"].ProviderName;
            }
            else
            {
                throw new ConfigurationErrorsException(_exNoConnectionStringFound);
            }
        }
        private string GetMinutesInPastToDelete()
        {
            string strReturn = "-60";
            if (null != System.Configuration.ConfigurationManager.AppSettings["MinutesInPastToDeletePageState"])
            {
                strReturn = System.Configuration.ConfigurationManager.AppSettings["MinutesInPastToDeletePageState"].ToString();
            }
            return (strReturn);
        }
    }
    #endregion

    AppleiPhone.cs file:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    /// <summary>
    /// Summary description for AppleIPhone
    /// </summary>
    public class AppleIPhone
    {
     public AppleIPhone()
     {
      //
      // TODO: Add constructor logic here
      //
     }

        static public bool IsIPhoneOS()
        {
            return (IsIPad() || IsIPhone() || IsIPodTouch());
        }

        static public bool IsIPhone()
        {
            return IsTest("iPhone");
        }

        static public bool IsIPodTouch()
        {
            return IsTest("iPod");
        }

        static public bool IsIPad()
        {
            return IsTest("iPad");
        }

        static private bool IsTest(string Agent)
        {
            bool bl = false;
            string ua = HttpContext.Current.Request.UserAgent.ToLower();
            try
            {
                bl = ua.Contains(Agent.ToLower());
            }
            catch { }
            return (bl);
       
        }
    }

    Master page .cs:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public partial class MasterPages_iPhoneMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                HtmlHead head = Page.Header;
                HtmlMeta meta = new HtmlMeta();
                if (AppleIPhone.IsIPad() == true)
                {
                    meta.Content = "width=400,user-scalable=no";
                    head.Controls.Add(meta);
                }
                else
                {
                    meta.Content = "width=device-width, user-scalable=no";
                    meta.Attributes.Add("name", "viewport");
                }
                meta.Attributes.Add("name", "viewport");
                head.Controls.Add(meta);
                HtmlLink cssLink = new HtmlLink();
                HtmlGenericControl script = new HtmlGenericControl("script");
                script.Attributes.Add("type", "text/javascript");
                script.Attributes.Add("src", ResolveUrl("~/Scripts/iWebKit/javascript/functions.js"));
                head.Controls.Add(script);
                cssLink.Attributes.Add("rel", "stylesheet");
                cssLink.Attributes.Add("href", ResolveUrl("~/Scripts/iWebKit/css/style.css") );
                cssLink.Attributes.Add("type", "text/css");
                head.Controls.Add(cssLink);
                HtmlGenericControl jsLink = new HtmlGenericControl("script");
                //jsLink.Attributes.Add("type", "text/javascript");
                //jsLink.Attributes.Add("src", ResolveUrl("~/Scripts/jquery-1.4.1.min.js") );
                //head.Controls.Add(jsLink);
                HtmlLink appleIcon = new HtmlLink();
                appleIcon.Attributes.Add("rel", "apple-touch-icon");
                appleIcon.Attributes.Add("href", ResolveUrl("~/apple-touch-icon.png"));
                HtmlMeta appleMobileWebAppStatusBarStyle = new HtmlMeta();
                appleMobileWebAppStatusBarStyle.Attributes.Add("name", "apple-mobile-web-app-status-bar-style");
                appleMobileWebAppStatusBarStyle.Attributes.Add("content", "black");
                head.Controls.Add(appleMobileWebAppStatusBarStyle);
        }

        internal string FindPath(string Location)
        {
            string Url = Server.MapPath(Location);
            return (Url);
        }
    }

  • ASP.NET Podcast Show #147 - Webmatrix/Razor Part II

  • ASP.NET Podcast Show #146 - WebMatrix/Razor Part 1

  • ASP.NET Podcast Show #145 - Windows Azure Part III with the Visual Studio 2010 and Azure 1.2 Tools

    This show is on Web & Worker Roles  in Azure, Blob Storage, and the Visual Studio 2010 Azure tools.

     

    Subscribe to everything.

    Subscribe to WMV.

    Subscribe to M4V for iPhone/iPad.

    Subscribe to MP3.

    Download WMV.

    Download MOV.

    Download M4V for iPhone/iPad.

    Download MP3.
  • ASP.NET Podcast Show #144 - Windows Azure Part II - Worker Roles

    This show is on Web & Worker Roles in Azure, Blob Storage, and the Visual Studio 2010 Azure tools.

    Subscribe to everything.

    Subscribe to WMV.

    Subscribe to M4V for iPhone/iPad.

    Subscribe to MP3.

    Download WMV.

    Download MOV.

    Download M4V for iPhone/iPad.

    Download MP3.

  • ASP.NET Podcast Show #143 - Windows Azure Part I - Web Roles

    This show is on Web Roles in Azure, Blob Storage, and the Visual Studio 2010 Azure tools.

    Subscribe to everything.

    Subscribe to WMV.

    Subscribe to M4V for iPhone/iPad.

    Subscribe to MP3.

    Download WMV.

    Download MOV.

    Download M4V for iPhone/iPad.

    Download MP3.

  • ASP.NET Podcast Show #142 - MonoTouch - iPhone Development with .NET/C# - Video & Audio

    Subscribe to Everything.

    Subscribe to WMV.

    Subscribe to M4V.

    Subscribe to MP3.

    Download WMV.

    Download M4V.

    Download MOV.

    Download MP3.

    Show Notes:

    PS.  This show is a little different than the others.  It was originally recorded for a user group that I am not able to travel to.
  • ASP.NET Podcast Show #141 - Angel and Venture Financing for Technology Professionals with Rachael Qualls

    Subscribe to Everything.

    Subscribe to WMV.

    Subscribe to M4V.

    Subscribe to MP3.

    Download WMV.

    Download  M4V for iPod.

    Download MP3.

    Show Notes:

    Personal Note from Wally: My favorite quote from the discussion: "We're not looking for an ad-based play."
  • ASP.NET Podcast Show #140 - ASP.NET 4.0 Ajax Databinding

    Subscribe to Everything.

    Subscribe to WMV.

    Subscribe to M4V.

    Subscribe to MP3.

    Download WMV.

    Download M4V.

    Download MP3.

    Show Notes:

    PS. I started getting sick about 5-10 minutes into the show, so if I sound somewhat confusing after that, I apologize.

    Source Code:

    <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Content.aspx.cs" Inherits="TwitterApp.Content" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    </asp:Content>

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <asp:ScriptManager ID="sm" runat="server">

    <Scripts>

    <asp:ScriptReference ScriptMode="Inherit" Name="MicrosoftAjax.js" Path="~/js/MicrosoftAjax.js" />

    <asp:ScriptReference ScriptMode="Inherit" Path="~/js/MicrosoftAjaxAdoNet.js" />

    <asp:ScriptReference ScriptMode="Inherit" Path="~/js/MicrosoftAjaxTemplates.js" />

    </Scripts>

    <Services>

    <asp:ServiceReference Path="~/TwitterService.svc" />

    </Services>

    </asp:ScriptManager>

    <asp:TextBox ID="Status" runat="server"

    TextMode="MultiLine" Rows="2" Columns="70" /><br />

    <input type="button" ID="btnSubmit"

    onclick="SubmitStatus()" value="Submit Status" />

    <hr width="98%" />

    <script language="javascript" type="text/javascript">

    var userName = "More_Wally";

     

    function SubmitStatus() {

    var Status = $get('<%=Status.ClientID %>');

    var userStatus = Status.value;

    Status.value = "";

    TwitterService.SubmitUserStatus(userName, userStatus,

    TwitterPostCallBack);

    }

    function TwitterPostCallBack(result) {

    TwitterService.GetUserTimeLine(userName,

    TwitterServiceCallBack, TwitterServiceFailure);

    }

    var dv;

    function pageLoad() {

    var tblS = $get("tblStatus");

    var uiElement = $get("twitterFriendsTimeLineListView");

    dv = new Sys.UI.DataView(uiElement);

    dv.add_itemCreated(fillExtra);

    dv.initialize();

    TwitterService.GetFriends(userName, StoreFriendsCallBack);

    TwitterService.GetUserTimeLine(userName, TwitterServiceCallBack, TwitterServiceFailure);

    }

    var dd;

    function StoreFriendsCallBack(result) {

    dd = result;

    }

    function TwitterServiceCallBack(result) {

    dv.set_data(result);

    //dv.updated();

    //tblStatus.style.visibility = "visible";

    }

    function FriendsCallBack(result, userCtx) {

    dd = result;

    DisplaySelect(dd, userCtx);

    }

    function DisplaySelect(data, userCtx) {

    var i;

    var opt;

    var sel = $get("to" + userCtx.index);

    sel.options.add(new Option("", ""));

    for (i = 0; i < data.length; i++) {

    opt = new Option(data[i].name, data[i].screen_name);

    sel.options.add(opt);

    }

    }

    var i = 0;

     

    function fillExtra(sender, Args) {

    var ctx = Args.get_templateContext();

    var dt = Args.get_dataItem();

    var strOut = "";

    var strReturn = "<br />";

    var Out = $get("Output");

    var userCtx =

    {

    index: ctx.index

    }

     

    if (i == 0) {

    strOut = "ctx<br />";

    for (m in ctx) {

    strOut += m + strReturn;

    }

    strOut += "<br/>ctx.nodes[0]<br />";

    for (m in ctx.nodes[0]) {

    strOut += m + strReturn;

    }

    strOut += "<br/>Data Item:<br />";

    for (m in dt) {

    strOut += m + strReturn;

    }

    Out.innerHTML = strOut;

    }

    i++;

    if (dd == null) {

    TwitterService.GetFriends("More_Wally", FriendsCallBack, null, userCtx);

    }

    else {

    DisplaySelect(dd, userCtx);

    }

    }

    function TwitterServiceFailure(result) {

    alert("An error occurred");

    }

    function IterateDV() {

    var count = dv.get_items().length;

    var rw = "";

    var controlId;

    var ctx = dv.get_templateContext()

    for (i = 0; i < count; i++) {

    if (i == 0) {

    //rw = dv.get_items()[i].elements[0].childNodes[2].childNodes[0].innerHTML;

    rw = $get("Number" + i).innerHTML;

    }

    else {

    rw += "," + $get("Number" + i).innerHTML;

    }

    }

    alert(rw);

    }

    function SendMessage(i) {

    var userName = "More_Wally";

    var sendTo = $get("to" + i).value;

    var userStatus = $get("message" + i).value;

    TwitterService.DMSend(userName, sendTo, userStatus,

    TwitterPostCallBack, TwitterServiceFailure);

    }

    String.prototype.parseURL = function() {

    var URL = /[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/;

    var matches = this.match(URL);

    var stringToReplace = this;

    while (matches != null ) {

    var m = matches[0];

    var url = "<a href='" + m + "'>" + m + "</a>";

    stringToReplace = stringToReplace.replace(m, url);

    matches = stringToReplace.substring(stringToReplace.indexOf(url) +

    url.length).match(URL);

    }

    return (stringToReplace);

    };

    String.prototype.parseUsername = function() {

    var userName = /[@]+[A-Za-z0-9-_]+/;

    var matches = this.match(userName);

    var stringToReplace = this;

    while ( matches != null ) {

    var m = matches[0];

    var finalMatch = m.replace("@", "");

    var url = "<a href='http://twitter.com/" + finalMatch + "' target='_new'>" + m + "</a>";

    stringToReplace = stringToReplace.replace(m, url);

    matches = stringToReplace.substring(stringToReplace.indexOf(url) + url.length).match(userName);

    };

    return (stringToReplace);

    };

    String.prototype.parseHashtag = function() {

    var hashTag = /[#]+[A-Za-z0-9-_]+/;

    var matches = this.match(hashTag);

    var stringToReplace = this;

    while (matches != null) {

    var m = matches[0];

    var finalMatch = m.replace("#", "%23");

    var url = "<a href='http://search.twitter.com/search?q=" + finalMatch +

    "' target='_new'>" + m + "</a>";

    stringToReplace = stringToReplace.replace(m, url);

    matches = stringToReplace.substring(stringToReplace.indexOf(url) +

    url.length).match(hashTag);

    };

    return (stringToReplace);

     

     

    };

    </script>

    <input type="button" id="btnIterate"

    value="Iterate" onclick="IterateDV()" />

    <table>

    <tr valign="top" align="left">

    <td>

    <table id="tblStatus" >

    <thead>

    <tr>

    <th>

    User Name

    </th>

    <th>

    Status

    </th>

    <th>

    Number

    </th>

    </tr>

    </thead>

    <tbody id="twitterFriendsTimeLineListView"

    class="sys-template" >

    <tr>

    <td valign="top" align="left">

    {{UserName}}<br />

    <img sys:src="{{ ProfileImage }}" /><br />

    <span style="font-size:smaller">

    {{ StatusDate }}

    </span>

    </td>

    <td valign="top" align="left">

    <span code:after="$element.innerHTML=Status.parseURL().parseUsername().parseHashtag()" />

    <!--{{Status.parseURL().parseUsername().parseHashtag()}}--></td>

    <td>

    <div sys:id="{{ 'Number' + $index }}">{{ $index }}</div>

    <div code:if="($index % 2) == 0">even</div>

    <div code:if="($index % 2) == 1">odd</div>

    </td>

    </tr>

    <tr>

    <td>

    <select sys:id="{{ 'to' + $index }}" ></select>

    <input type="text" sys:id="{{ 'message' + $index }}" size="50" />

    </td>

    <td>

    <input type="button" sys:id="{{ 'btn' + $index }}"

    value="Send a direct message" onclick="{{ 'SendMessage(' + $index + ')' }}" />

    </td>

    </tr>

    <tr>

    <td colspan="2">

    2 way data binding<br />

    { binding Status }<br />

    <input type="text" value="{ binding Status }" />

    </td>

    </tr>

    <tr>

    <td colspan="2">

    <div code:before="if (i != 19) {" code:after="}">break</div>

    <hr width="98%" code:if="$index != 19" />

    </td>

    </tr>

    </tbody>

    </table>

    </td>

    <td>

    <div id="Output">

    </div>

    </td>

    </tr>

    </table>

    </asp:Content>

     

    Images:

  • ASP.NET Podcast Show #139 - David Penton and Pat Helland on Cloud Computing - audio

  • ASP.NET Podcast Show #138 - Coding Microsoft Velocity with David Penton - video

    Subscribe to All!

    Subscribe to WMV.

    Subscribe to M4V (iPod).

    Subscribe to MP3.

    (The cool kids subscribe, why not you?!?)

    Download WMV.

    Download M4V.

    Download MP3.

    Code Samples: http://www.aspnetpodcast.com/CS11/files/folders/podcastsupportfiles/entry1293.aspx

    Show Notes:

    ----- Code Sample Notes -----

    • Four (4) assembly references are needed for a cache project:
    • CacheBaseLibrary.dll
    • CASBase.dll
    • ClientLibrary.dll
    • FabricCommon.dll
    • Import System.Data.Caching for code using Velocity
    • You must start with a CacheFactory. No parameters in the construct means to read from a configuration file.
    • From there, cache is accessed via a CacheName. You can use Cache.DefaultCache for the default (returns null) For CTP2, you cannot easily seek out if a region is created.
    • Cache.DefaultRegion is null as well.
    • There is quite a bit of log messages that are exposed by default in Velocity. Especially for a Cache Miss.

    Format: wmv
    Duration: 23:00

  • ASP.NET Podcast Show #137 - Install and Configuration of Microsoft Velocity with David Penton - video

    Subscribe to All!

    Subscribe to WMV.

    Subscribe to M4V (iPod).

    Subscribe to MP3.

    (The cool kids subscribe, why not you?!?)

    Download WMV.

    Download M4V.

    Download MP3.

    Show Notes:

    ----- Installation Notes -----

    • CTP1 must be uninstalled first!
    • .Net Framework version 3.5
    • PowerShell version 1.0
    • Cluster configuration options
    • XML based
    • SQL Server (or SQL CE) based
    • Set cache cluster/host options
    • Cluster Name
    • Cluster Size: small (1-3), medium (4-6), large (7-10)
    • Cache Host port (default 22233)
    • Cache Cluster port (if configuring) (default 22234)
    • Max Server Memory

    ----- Configuration Notes -----

    • XML Configuration file or SQL Server
    • PowerShell is the de-facto configuration tool Desktop icon is created during installation for the PowerShell entrance Keep in mind that any parameter values are case-sensitive Basic help comes from
    • Get-CacheHelp
    • Other typical options (some have obvious names)
    • Start-CacheCluster
    • Stop-CacheCluster
    • Restart-CacheCluster
    • Get-Cache (shows the current Cache Names available and the regions)
    • New-Cache (creates a new cache name)
    • Remove-Cache (removes an existing cache name)
    • Get-CacheConfig (shows statistics for the cache node specified)
  • ASP.NET Podcast Show #136 - Rachel Appel on Dynamic Data

    Subscribe to everything.

    Subscribe to MP3.

    Download.

    Show Notes:

    PS. Apologies for the delay as I have been sick and concentrating on other things.
  • ASP.NET Podcast Show #135 - Development Methodologies as Religion

    Subscribe to all

    Subscribe to MP3 only

    Download

    Show Notes:

    • Superbowl, football, Cowboys (you have got to be kidding me).
    • Refactoring, TDD, and the great religious debates of software systems.
    • Coaching systems. Great Players make Great Coaches. Systems need to be molded to players.  Don't force one size fits all.
    • Ok, I feel better now.
More Posts Next page »

This Blog

Syndication

Powered by Community Server, by Telligent Systems