Archive for the ‘ ASP.NET’ Category

Building a Training Calendar Application

I spent some time with the VP of an interesting company recently.

The company is pretty good size (several hundred million dollars in revenue and many hundreds of employees).

The company sells products, services, and training. The training segment of the business represents a very small percentage of the actual corporate revenue but is a key strategy in the company’s brand identity, customer satisfaction strategy and instrumental in the supporting the sales of products and services.

Historically the company has run a successful training operation but not done an optimal job at synergizing the operations.

Lake most companies, they have many disparate systems (AR, CRM, ERP, etc.)

The problem seemed so interesting top me that I thought I’d use it as the basis for a sample application oversize.

Phase #1 will be implementing the basic data handling features for a training company.

  • Each course will be given many times a year.
  • Each course instance can be given at multiple locations.
  • Each location has different facilities.
  • Each course is part of a curriculum and must be organizational by that identity.
  • Each course has prerequisites and requirements.
  • Each course may be given by multiple instructors and instructor identical is an index.
The following is a Viso draft of the schema. (Click to see the full size image.)

As I get ready to begin implementation, please make any comments and feature suggestions below.

Filtering an ASP.NET GridView control with jQuery

 As I’ve been swimming in the great jQuery lake I discovered the jQuery QuickSearch Plugin,

As WebForms developers we often display lots of data using a gridview control.

I though it would be neet to set up using the jQuery QuickSearch plugin with the Gridview.

Here’s how it works.

Ihave a GridView wired to some sample data. For demo simplicity I’m using an XMLDataSource and reading from an XML file in my App_Data directory.

When the user starts to type into the Filter Text Box the rows in the table are filtered, meaning rows that don’t match the character(s) entered are hidden from view.

As the user continues to type, the list is filtered further.

The ASPX Page Markup is as follows.
Read the rest of this entry »

ASP.NET Dropdown Search with jQuery

The Ajax Control Toolkit includes a ListSearch [ see HERE ] control extender that can me used to extend a list or drop down list with a filtering feature by which the control will start to narrow the available options in the list to the ones that include the characters that the user has entered.

So when we use a drop down list for the selection of an item, and we enter (set focus) on the control, then the control expands. 

Then when we start to type, we want the list to hide items that do not contain the character sequence that we have typed.

I’ve implemented this feature using Unobtrusive Fast-filter Dropdown

Implementing this plugin (abbreviated UFD) with an ASP.NET DropDownList is easy.


<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
    AutoEventWireup='true' CodeFile='Default.aspx.cs' Inherits='_Default' %>

<asp:Content ID='HeaderContent' runat='server'
                                ContentPlaceHolderID='HeadContent'>
    <link href='Content/themes/redmond/jquery-ui.css' rel='stylesheet'
                                                      type='text/css' />
    <link href='Styles/udf/ufd-base.css' rel='stylesheet' type='text/css' />
    <link href='Styles/udf/plain/plain.css' rel='stylesheet'
                                            type='text/css' />
    <script src='Scripts/jquery-1.4.4.js' type='text/javascript'></script>
    <script src='Scripts/jquery-ui-1.8.13.js' type='text/javascript'></script>
    <script src='Scripts/jquery.ui.ufd.js' type='text/javascript'></script>
</asp:Content>
<asp:Content ID='BodyContent' runat='server'
                              ContentPlaceHolderID='MainContent'>
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit
        <a href='http://www.asp.net' title='ASP.NET Website'>www.asp.net</a>.
    </p>
    <p>
        You can also find
        <a href='http://go.microsoft.com/fwlink/?LinkID=152368&clcid=0x409'
            title='MSDN ASP.NET Docs'>documentation on ASP.NET at MSDN</a>.
    </p>
    <hr />

    <label for='SelectCountry'>Choose a country:</label><br /><br />

    <asp:DropDownList id='SelectCountry' name='SelectCountry' runat='server'
                      ClientIDMode='Static'>
        <asp:ListItem Text='Afghanistan' Value='Afghanistan'></asp:ListItem>
        <asp:ListItem Text='Albania' Value='Albania'></asp:ListItem>
        <asp:ListItem Text='Algeria' Value='Algeria'></asp:ListItem>
        <asp:ListItem Text='Bahrain' Value='Bahrain'></asp:ListItem>
        <asp:ListItem Text='Bangladesh' Value='Bangladesh'></asp:ListItem>
        <asp:ListItem Text='Barbados' Value='Barbados'></asp:ListItem>
        <asp:ListItem Text='Cambodia' Value='Cambodia'></asp:ListItem>
        <asp:ListItem Text='Cameroon' Value='Cameroon'></asp:ListItem>
        <asp:ListItem Text='Canada' Value='Canada'></asp:ListItem>
    </asp:DropDownList>

    <br/>

    <script type='text/javascript' >
        $(function () {
            $('#SelectCountry').ufd({ log: true });
        });
    </script>

</asp:Content>

You can garb the working example [ HERE ]


ASP.NET User Input via the jQuery UI Slider

The Ajax Control Toolkit includes a “Slider” and a “MultiHandleSlider” control extender that lets your user fill a textbox with a numeric value by dragging one or more markers along a line or “axis”.

One “slider” means manipulating one value, multiple sliders means manipulating multiple values.

This is another way to add a visual component to data entry, which may be faster, or lead to greater accuracy and convenience when data is being entered.

I’m replacing the Ajax Control Toolkit slider with the jQuery UI Slider.

Here is a screen shot of the working sample.

And here is our page markup :


<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
    AutoEventWireup='true' CodeFile='Default.aspx.cs' Inherits='_Default' %>

<asp:Content ID='HeaderContent' runat='server'
                                ContentPlaceHolderID='HeadContent'>
<link href='Content/themes/base/jquery.ui.all.css' rel='stylesheet'
                                                   type='text/css' />
<script src='Scripts/jquery-1.4.4.js' type='text/javascript'></script>
<script src='Scripts/jquery-ui-1.8.13.js' type='text/javascript'></script>
<style>
    .valueout
    {
        border: 0;
        color:#f6931f;
        font-weight:bold;
    }
</style>
<script type='text/javascript'>
    $(function () {
        // Add one slider to the first target DIV.
	    $('#slider').slider({
	        value: 100,
	        min: 0,
	        max: 500,
	        step: 50,
	        slide: function (event, ui) {
	            $('#amount').val('$' + ui.value);
	        }
	    });
	    $('#amount').val('$' + $('#slider').slider('value'));

	    // Add two sliders to the second target DIV.
	    $('#slider-range').slider({
	        range: true,
	        min: 0,
	        max: 500,
	        values: [75, 300],
	        slide: function (event, ui) {
	            $('#amountrange').val('$' + ui.values[0]
				                          + ' - $' + ui.values[1]);
	        }
	    });
	    $('#amountrange').val('$' + $('#slider-range').slider('values', 0) +
		                   ' - $' + $('#slider-range').slider('values', 1));

	});
</script>

</asp:Content>
<asp:Content ID='BodyContent' runat='server'
                              ContentPlaceHolderID='MainContent'>
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit
        <a href='http://www.asp.net' title='ASP.NET Website'>www.asp.net</a>.
    </p>
    <hr />

	<label for='amount'>Donation amount ($50 increments):</label><br /><br />
    <asp:TextBox ID='amount' CssClass='valueout' runat='server'
                 ClientIDMode='Static'>
    </asp:TextBox>
    <br /><br />
    <div id='slider' style='width: 300px;'></div><br />

    <hr />
    <asp:Button ID='Button1' runat='server' Text='Submit'
	                                        onclick='Button1_Click' />
    <br /><br />
    <asp:Label ID='LabelTestResult' runat='server' Text=''></asp:Label>
    <hr />

	<label for='amountrange'>Range:</label>
    <asp:TextBox ID='amountrange' CssClass='valueout' runat='server'
                                  ClientIDMode='Static'>
    </asp:TextBox><br /><br />
    <div id='slider-range'  style='width: 300px;'></div>

</asp:Content>

The actual value is a string stored in the textboxes created on lines #58 and #71.

Note the setting of the initial value, min, max, step, and range parameters.

Note also lines #28 and #40 where slider value is used to set our textboxes.

Since those text boxes are ASP.NET Server Side controls we can easily access them in our code-behind.


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

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        LabelTestResult.Text = 'Thanks - ' + amount.Text
		                                   + ' is a lot of money!';
    }
}

You can download a working sample [ HERE ]


Numeric Up Down Input using the jQuery UI Spinner

The AJAX Control Toolkit includes a Numeric Up/Down Control Extender that lets you turn a text box into a numeric Up / Down input control.

There is a slick jQuery UI plugin – the jQuery UI Spinner - that lets us do this without the Ajax Control Toolkit and have pretty detailed control over the way our input works.

Some of the built-in capabilities include:

  • Mouse Wheel Support
  • Control over the Mouse Wheel Increment sensitivity
  • Variable “step” increments
  • Set-able Minimum and Maximum Values

Here is our demo UI.

And here is our code :


<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
         AutoEventWireup='true' CodeFile='Default.aspx.cs'
		 Inherits='_Default' %>

<asp:Content ID='HeaderContent' runat='server'
             ContentPlaceHolderID='HeadContent'>
<link href='Content/themes/base/jquery.ui.all.css' rel='stylesheet'
      type='text/css' />
<link href='Styles/Site.css' rel='stylesheet' type='text/css' />
<link href='Styles/ui.spinner.css' rel='stylesheet' type='text/css' />
<script src='Scripts/jquery-1.4.4.js' type='text/javascript'></script>
<script src='Scripts/jquery-ui-1.8.13.js' type='text/javascript'></script>
<script src='Scripts/ui.spinner.js' type='text/javascript'></script>
<script type='text/javascript'>
jQuery().ready(function ($) {
	$('#updown').spinner({ min: -100, max: 100 });
	$('#updownfast').spinner({ min: -1000, max: 1000, increment: 'fast' });
	$('#updownhide').spinner({ min: 0, max: 100, showOn: 'both' });
	$('#updownnull').spinner({ min: -100, max: 100, allowNull: true });
	$('#updowndisable').spinner({ min: -100, max: 100 });
	$('#updownmaxlen').spinner();

	$('#updownconfig').spinner(
	   { min: -1000, max: 1000, step: 1, increment: 'fast' }
	   );
	$('#updownmax').spinner().change(function ()
	   { $('#updownconfig').spinner('option', 'max',
	                                 parseInt($(this).val())); }
	   );
	$('#updownmin').spinner().change(function ()
	   { $('#updownconfig').spinner('option', 'min',
	                                 parseInt($(this).val())); }
	   );
	$('#updownstep').spinner().change(function ()
	   { $('#updownconfig').spinner('option', 'step',
	                                 parseInt($(this).val())); }
	   );
	$('#updownspeed').change(function ()
	   { $('#updownconfig').spinner('option', 'increment', $(this).val()); }
	   );
	$('#updownmousewheel').change(function ()
	   { $('#updownconfig').spinner('option','mouseWheel',
	                                 $(this).is(':checked')); }
	   );
	$('#enable').click(function ()
	 { $('#updowndisable').spinner('enable'); });
	$('#disable').click(function ()
	 { $('#updowndisable').spinner('disable'); });
	$('#GetValue').click(function ()
	 { alert($('#updown').spinner('value')); });
	$('#destroy').click(function ()
	 { $('#updown').spinner('destroy'); });

});
</script>
</asp:Content>
<asp:Content ID='BodyContent' runat='server'
     ContentPlaceHolderID='MainContent'>
<h2>
    Welcome to ASP.NET!
</h2>
<br />
Up Down :
<asp:TextBox ID='updown' runat='server' ClientIDMode='Static' Text='0'>
</asp:TextBox>
<input type='button' id='GetValue' value='Get Value' />
<input type='button' id='destroy' value='Destroy' />
<br /><br />

Fast Up / Down :
<asp:TextBox ID='updownfast' runat='server' ClientIDMode='Static' Text='0'>
</asp:TextBox>
<br /><br />

Up / Dopwn Hidden:
<asp:TextBox ID='updownhide' runat='server' ClientIDMode='Static' Text='0'>
</asp:TextBox> Except for  When Active !
<br /><br />   

<hr />
<div id='example'>
<table class='grid'>
  <tr>
     <td>Configurable Up/Down:</td>
     <td>
     <asp:TextBox ID='updownconfig' runat='server'
	              ClientIDMode='Static' Text='0'>
     </asp:TextBox>
     </td>
   </tr>
   <tr>
      <td>Maximum:</td>
      <td>
      <asp:TextBox ID='updownmax' runat='server'
	               ClientIDMode='Static' Text='1000'>
      </asp:TextBox>
      </td>
   </tr>
   <tr>
      <td>Minimum:</td>
      <td>
      <asp:TextBox ID='updownmin' runat='server'
	               ClientIDMode='Static' Text='-1000'>
      </asp:TextBox>
      </td>
   </tr>
   <tr>
      <td>Step:</td>
      <td>
      <asp:TextBox ID='updownstep' runat='server'
	               ClientIDMode='Static' Text='1'>
      </asp:TextBox>
      </td>
   </tr>
   <tr>
      <td>Speed:</td>
      <td>
         <select id='updownspeed'>
            <option value='slow'>Slow</option>
            <option selected='selected' value='fast'>Fast</option>
         </select>
      </td>
   </tr>
   <tr>
      <td>Mouse Wheel:</td>
      <td>
         <input type='checkbox' id='updownmousewheel' checked='checked' />
      </td>
   </tr>
</table>
</div>
<hr />
<br />
    <asp:Button ID='ButtonSubmit' runat='server' Text='Submit'
        onclick='ButtonSubmit_Click' /><br /><br />
    <asp:Label ID='LabelResult' runat='server' Text=''></asp:Label>
</asp:Content>

The ui.spinner.css file takes care of positioning the Up / Down buttons next to the text bix that they will apply to.

Note that in the body of the markup the text boxes can be either html input elements with type set equal to text or ASP.NET TextBox controls with the ClientIdMode set to static.

Whichever way you choose you can specify a starting numberic value as a string.

The “magic” happens in the jQuery code that you see above between lines 11 and 44.

I think the code’s functionality is pretty straight forward and looking at the code reveals many of the optional parameters.

Simplifying user input helps reduce data input errors!

You can download a working sample [ HERE ].


Embedding a jQuery HTML Input Editor in an ASP.NET page.

Sometimes we need users to be able to enter fomated input / text.

There are many embedable WYSIWYG HTML inpt boxes available. [ See HERE ]

I chose HTMLBox 4.01 becuase it is easy to style [ DEMO HERE ] but there are many good ones and you should pick the one that best meets your needs.

My implementation looks like this.

When I’ve entered some formatted text I can switch to HTML view and see the markup.

One of the things tat I especially like about HTMLBox is that it exposes events for the appropriate icons like “File Open”

My page markup looks like this:


<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
         AutoEventWireup='true' CodeFile='Default.aspx.cs'
         Inherits='_Default'  %>

<asp:Content ID='HeaderContent' runat='server'
             ContentPlaceHolderID='HeadContent'>
    <script src='Scripts/jquery-1.4.1.js' type='text/javascript'></script>
    <script src='Scripts/com.remiya.jquery.codify.min.js'
	        type='text/javascript'>
    </script>
    <script src='Scripts/htmlbox.colors.js' type='text/javascript'></script>
    <script src='Scripts/htmlbox.styles.js' type='text/javascript'></script>
    <script src='Scripts/htmlbox.syntax.js' type='text/javascript'></script>
    <script src='Scripts/htmlbox.undoredomanager.js' type='text/javascript'>
    </script>
    <script src='Scripts/htmlbox.full.js' type='text/javascript'></script>
    <script type='text/javascript'>
        $(function () {

        });
    </script>
</asp:Content>
<asp:Content ID='BodyContent' runat='server'
             ContentPlaceHolderID='MainContent'>
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit
        <a href='http://www.asp.net' title='ASP.NET Website'>www.asp.net</a>.
    </p>
<h2>HTML Input</h2>

<asp:TextBox ID='htmlbox' runat='server' TextMode='MultiLine' Rows='20'
             Columns='80' ClientIDMode='Static'></asp:TextBox><br />
<asp:Button ID='SubmitButton' runat='server' Text='Submit'
            onclick='SubmitButton_Click' /><br /><br />

<asp:Label ID='LabelResult' runat='server'></asp:Label>

<script  type='text/javascript'>
var hb_icon_set_blue;
hb_icon_set_blue = $('#htmlbox').css('height', '100')
                                .css('width', '600').htmlbox({
   toolbars: [
	         ['cut', 'copy', 'paste', 'separator_dots', 'bold', 'italic',
              'underline', 'strike', 'sub', 'sup', 'separator_dots', 'undo',
              'redo', 'separator_dots', 'left', 'center', 'right', 'justify',
              'separator_dots', 'ol', 'ul', 'indent', 'outdent',
              'separator_dots', 'link', 'unlink', 'image'],
		      ['code', 'removeformat', 'striptags', 'separator_dots',
			   'quote','paragraph', 'hr', 'separator_dots',
              { icon: 'new.gif', tooltip: 'New', command: function ()
                                { hb_icon_set_blue.set_text('<p></p>'); } },
			 { icon: 'open.gif', tooltip: 'Open', command: function ()
                                { alert('Open') } },
			 { icon: 'save.gif', tooltip: 'Save', command: function ()
                                { alert('Save') } }
		  ]
	],
        icons: 'default',
        skin: 'blue'
    });
</script>

</asp:Content>

But, just adding the jQUery and HTML Box libraries to our page and wiring the jQuery plugin to an ASP.NET Multi Line Textbox will not get us to where we really need to be.

If we do just that muich and run our page we will see this error.



The above is generated by a built in security feature of .NET that prevents the user from submitting markup or anything that might be a security concern.

We’ll need to tell ASP.NET to allow markup to be posted back

WARNING: Doing this means we are explicitly telling ASP.NET that we will be responsable for making sure that whatthe user posts back to the server is SAFE ! – All user input should be considered evil untill we prove otherwise.

In order to permit the markup to be posted back we need to do two things,

1.) We need to add a directive to the system.web section of the web.config file and set the Validation Mode to 2.0


  <system.web>
      <httpRuntime requestValidationMode='2.0' />
  </system.web>

2.) Then, in the page itself we need to add a page directive to tell ASP.NET not to validate the page


<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
         AutoEventWireup='true' CodeFile='Default.aspx.cs'
         Inherits='_Default' ValidateRequest='false' %>

Now the page will submit.

Since we turned validation off, we should insure security before we use whatever the user entered in the WYSIWYG box. (Like storing it in a database or displaying it on a page.

In our button click event handler we simply encode the text box value before we use it.


    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        LabelResult.Text = Server.HtmlEncode(htmlbox.Text);
    }

You can download a working ASP.NET 4 sample [ HERE ]


Replacing the Ajax Control Toolkit DragPanel Control Extender with jQuery

The Ajax Control Toolkit includes a DropPanel Control Extender that lets you drag and drop content thereby moving it around on your web page [ more HERE ]. 

jQuery, or more specifically jQueryUI has Drag-and-Drop built-in.

Yup – like a lot of stuff in this series that means it’s just REALLY easy to get the effect you want using jQuery

Since this series is about showing how to do with jQuery the sort of things you would have previously done with the Ajax Control Toolkit, I’m going to defer catching the “drop” events to a future entry.

Here is the effect we’re looking for.

 

Drag and Drop …..

After including jQuery and jQUeryUI  (script & CSS) here is the code for the page.


<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
         AutoEventWireup='true' CodeFile='Default.aspx.cs'
                        Inherits='_Default' %>

<asp:Content ID='HeaderContent' runat='server'
                                ContentPlaceHolderID='HeadContent'>
    <link href='Styles/jquery-ui-1.8.13.custom.css' rel='stylesheet'
                                                type='text/css' />
</asp:Content>
<asp:Content ID='BodyContent' runat='server'
                              ContentPlaceHolderID='MainContent'>
    <h2>Draggable Panel !</h2>
    <br />
    <div class=demo>
        <div id=draggable class=ui-widget-content>
            <p>
            <br />
            I'm an AJAX Draggable Container.
            <br /><br />
            You could catch drop events and build a configurable UI.

            </p>
        </div>
    </div>

    <div>
        <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        Mauris varius ullamcorper lacus, ac pharetra libero commodo eu.
        Aenean auctor imperdiet libero, sit amet scelerisque lorem placerat
        quis. Phasellus pretium, lacus eget euismod cursus, nunc nibh semper
        urna, at blandit elit nisl non dui. Sed blandit dignissim tellus,
        in egestas orci facilisis vel. Curabitur consequat ante vel mauris
        accumsan rutrum. Aliquam lorem est, ornare eget mollis sit amet,
        vestibulum et diam. Phasellus cursus massa sodales metus
        luctus sed blandit quam rhoncus. Proin nunc risus, scelerisque eu
        sagittis in, gravida vitae lectus. Maecenas et ipsum ac mauris
        condimentum accumsan ac et ligula. Phasellus mattis, tortor quis
        rutrum mollis, ante eros dictum leo, ac venenatis augue nisl sit
        amet mauris. Maecenas cursus, arcu nec egestas molestie, leo
        lectus pellentesque sapien, eu sollicitudin urna dolor vitae
        nisl. Proin lobortis, tortor quis congue lacinia, arcu elit
        consequat erat, vestibulum aliquet lorem massa sed leo. Suspendisse
        volutpat odio in mauris cursus aliquam. Nullam sed sapien sit amet mi
        laoreet sagittis. Integer rutrum lacus quis felis venenatis porta.
        </p>
    </div>         

    <script src='Scripts/jquery-1.4.1.js' type='text/javascript'></script>
    <script src='Scripts/jquery-ui-1.8.1.custom.min.js'
	                                     type='text/javascript'>
    </script>

    <style>
    #draggable { width: 150px; height: 150px; padding: 0.5em; }
</style>

    <script type='text/javascript'>
        $(function () {
            $('#draggable').draggable();
        });
    </script>
</asp:Content>

All we’re doing here is specifying a class to apply to the area that we want to be draggable then using a jQuery selector to access any page element that uses that class and calling the jQueryUI dragable() method.

Have fun !


Implementing Collapse Panels with jQuery.

The Ajax Control Toolkit has a Collapse Panel Control Extender [ see HERE ] that allows you to hide or show sections of content in your web page. This ability can be very useful as we evolve our UIs more toward “Single Page” interfaces.

There are many ways to accomplish this using jQuery and I’ve chosen a slick little plugin by Darren Ingram [ get it HERE ]

The UI behavior is simple. We have a set of content in a container (a div in this case)

When the user clicks on the title bar the container collapses leaving only the title bar.

The code is simple becuase the PlugIn does all the work for us.


<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
    AutoEventWireup='true' CodeFile='Default.aspx.cs' Inherits='_Default' %>

<asp:Content ID='HeaderContent' runat='server'
                                ContentPlaceHolderID='HeadContent'>
<link href='Styles/jquery-ui-1.8.13.custom.css' rel='stylesheet'
                                                type='text/css' />
</asp:Content>

<asp:Content ID='BodyContent' runat='server'
                              ContentPlaceHolderID='MainContent'>
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit
        <a href='http://www.asp.net' title='ASP.NET Website'>www.asp.net</a>.
    </p>
    <div class='collapsibleContainer' title='Example Collapsible Panel'>
	<p>
	Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris
	varius ullamcorper lacus, ac pharetra libero commodo eu. Aenean auctor
	imperdiet libero, sit amet scelerisque lorem placerat quis. Phasellus
	pretium, lacus eget euismod cursus, nunc nibh semper urna, at blandit
	elit nisl non dui. Sed blandit dignissim tellus, in egestas orci
	facilisis vel. Curabitur consequat ante vel mauris accumsan rutrum.
	Aliquam lorem est, ornare eget mollis sit amet, vestibulum et diam.
	Phasellus cursus massa sodales metus luctus sed blandit quam rhoncus.
	Proin nunc risus, scelerisque eu sagittis in, gravida vitae lectus.
	Maecenas et ipsum ac mauris condimentum accumsan ac et ligula.
	Phasellus mattis, tortor quis rutrum mollis, ante eros dictum
	leo, ac venenatis augue nisl sit amet mauris. Maecenas cursus, arcu nec
	egestas molestie, leo lectus pellentesque sapien, eu sollicitudin urna
	dolor vitae nisl. Proin lobortis, tortor quis congue lacinia, arcu elit
	consequat erat, vestibulum aliquet lorem massa sed leo. Suspendisse
	volutpat odio in mauris cursus aliquam. Nullam sed sapien sit amet mi
	laoreet sagittis. Integer rutrum lacus quis felis venenatis porta.
	</p>
    </div>  

    <script src='Scripts/jquery-1.4.1.js' type='text/javascript'></script>
    <script src='Scripts/jquery-ui-1.8.1.custom.min.js'
	             type='text/javascript'>
    </script>
    <script src='Scripts/diQuery-collapsiblePanel.js'
	             type='text/javascript'>
    </script>
    <script type='text/javascript'>
        $(document).ready(function () {
            $('.collapsibleContainer').collapsiblePanel();
        });
    </script>
</asp:Content>

In the example above the collapsable dic contains a text paragraph but try it with ASP.NET controls and you’ll find it works the same way.

Have fun !


Replacing the Animation Control Extender with jQuery Animations

Next up in this series is control animation.  The Ajax Control Toolkit has an Animation Control Extender [ see HERE ].

jQuery has animation built-in to its code [ see HERE ]

Basically, with jQuery animation you can animate any DOM object that you are access pragmatically.

Understand that animation is a huge subject and the variety of effects you can accomplish with jQuery animation is limited only by your imagination. One could write an entire book on jQuery animation and I’m not a “designer”.

I’ll show you a basic animation to get you started.

Here is the animation behavior I want.

Click on the image for a short video that shows the animation.

Here is the entire ASPX page.

Note that the positioning of the Button control is absolute and, for the sake of a simple demo, I’ve just hard-coded the position to work with a 1024×768 resolution. In production I’d have to dynamically determine the correct starting position.


<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
         AutoEventWireup='true' CodeFile='Default.aspx.cs'
		 Inherits='_Default' %>

<asp:Content ID='HeaderContent' runat='server'
             ContentPlaceHolderID='HeadContent'>
    <script src='Scripts/jquery-1.4.1.js' type='text/javascript'></script>
    <style>
    .block  {
        position:absolute;
        background-color:#abc;
        border-top-width: medium;
        left:30px;
        width:90px;
        height:90px;
        margin:5px;
        top: 280px;
        }
    </style>
</asp:Content>

<asp:Content ID='BodyContent' runat='server'
             ContentPlaceHolderID='MainContent'>
    <h2>jQuery has rich Animation.</h2>
    <p>
        <asp:Label ID='ResultLabel' runat='server' Text='&nbsp;'>
		</asp:Label><br />
    </p>

    <button id='left'>"</button> <button id='right'>"</button><br />
    <asp:Button ID='AnimatedButton' class='block' runat='server'
	            Text='ASP Button'
                ClientIDMode='Static' onclick='AnimatedButton_Click' />
    <br /><br /><br /><br />&nbsp;SECRET !
    <script type='text/javascript'>
        $('#right').click(function () {
            $('.block').animate({ 'left': '+=150px' }, 'slow');
        });

        $('#left').click(function () {
            $('.block').animate({ 'left': '-=150px' }, 'slow');
        }); 

    </script> 

</asp:Content>

By now (assuming that you have been following this series) you are starting to get comefortable with jQuery so the code should be pretty understandable. I’m simply using a selector to get the Botton Object by it’s class association (take note of the ClientId setting on the ASP.NET Button control) and calling the .animate method.

You can check out the documentation for all the available options here : http://api.jquery.com/animate/

Since I’m somewhat “creativly challenged”, here are some additional resources to help you get started with animation ideas.

Murach Web Development Books Updated to 4

MurachsADONET4CS  MurachsASPNET4CS

[ Click the books above to see them on Amazon ]

I’ve said for many years that were I ever to teach a university course on web development Murach’s books would be the textbooks that I would use.

Since many folks have emailed me to say that they used these books to learn ASP.NET I thought I’d let folks know that Murach has updated them to the 4 versions of .NET

The folks at Murach were nice enough to send me the latest versions and they are everything that I’ve come to expect from a Murach book.

The ASP.NET book is THE quintessential resource for learning ASP.NET Web Forms Development (yes, WebForms is still the #1 ASP.NET Development model by a significant margin).

It covers details of every aspect of ASP.NET Web Forms development. Two particularly interesting coverage areas are the use of WCF services and details  working with web applications on Windows 7.

The ADO.NET book not only provides tutorial on all the aspects of ADO.NET data access but walks you through building an application. Though there is the expected focus on LINQ, Entity Framework, etc. there is also coverage on other data like XML.

As always, You can’t go wrong.

In the previous post in this Contoso Karate MVC Series we re-factored our LogIn control widget into a PartialView. We did this for a few reasons.

  • Views want to be associated with only one model and we want to reserve that model for one that is more central to the particular page being displayed. (Specifying the Model for the view in the page _Template is generally a bad idea since that model will then be THE model assumed for every page that derives from that template. Partial views are one of the ways that we can solve this problem, a ViewModel is another.)
  • Partial views are very easily reusable.
  • If other considerations don’t preempt their use, Partial Views can make your actual View Markup easier to understand.

In this post I’ll build another Partial View. Please read the previous post to understand why we need partial views in the context of our fairly complex user interface design.

So, lets suppose that we have a requirement for an alert / notice box on our home page. It could contain special data, like for example a notice that classes are canceled due to bad weather.

It might look like this.

In this case our UI Widget is slightly more complex because we will need to retrieve data from a database to display from inside our partial view. We will store all the site notices in the database so that we have a historical record but we’ll only display the most recent one.

So, we’ll need a data table to store our notices. I like to keep the ASP.NET Services data (membership, etc) separate from my domain specific data so I created a new database named CKCMS for Contoso Karate Content Management System.

You probably know the drill. Right-Click in the solution, select Add -> New Item, choose the data items collection and select New SQL Server Database.

In Visual Studio, Switch from the Solution Explorer to the Database Explorer.

Expand the view on the database that was just created and right-click on the tables folder.

Add the fields as shown in the following table view.

When you save the table, name it “Notices”.

Note that the IsLive column will not be used in this demo. I’ve added it for future use. (We may want to be able to display more than one notice at a time in a future version of the application.)

Since we’ll need to access the data, I created an ADO.NET Entity Model.

Right-Click on the Models folder and choose add new item.

Select “Data” to see the data items collection and choose ADO.NET Entity Data Model and specify the name “CKSMSDBModel”  (Contoso Karate Content Management System Database Model.)
Read the rest of this entry »

Refactoring the Contoso Karate MVC LogOn Widget.

Just recently I published this post about creating a “logon widget” for the ASP.NET MVC Contoso Karate application that I’ve started building.

In this post I’m going to re-factor it.

Why, you ask? Well, sometimes it’s easiest to demonstrate techniques in a “simple” way  that is not necessary the most practical way.

Such is the case of our “login widget”.

ASP.NET MVC imposes a LOT of conventions. We could have technoligious discussions ad nauseam about why the MVC way is the best way (or not). I have FAR to many of these conversations but lets just agree that for some developer’s preferences and in certain types of application needs, the impositions of the pattern pay long-term dividends.

The idea of MVC (Model – View – Controller) lets us achieve “Separation of Concerns”. While this is not necessary (I know – sacrilege!) it is normally a beneficial thing. 

But, whenever a pattern or an implementation is meant to support a specific way of doing things it can get in the way.

The problem in this case is that a view (by default) sort of wants to be rendered using a SINGLE model.

take for example the following web site layout from a Joomla theme by RocketTheme

This is a pretty common kind of web user interface and one that will be very difficult to serve using a single data source.

You’ll recall from the previous post that we want the LogOn widget to appear on every page  but we accessed the model for the login data by referencing the LogOnModel that is innate to ASP.NET MVC applications that are created using the default ASP.NET MVC template.

It works fine, but our pages will stop working as soon as we try to reference an additional model in our views as views want a SINGLE model to work with.

No problem. Not only is there a way to do what we want (now that we understand the code that delivers the LogOn behavior that wer want) there is a much better, reusable way.

Enter “Partial Views”

Note that I’m not posting screen shots here because the User Interface will look and work EXACTLY like that you will find in the previous post referenced above.

To create a Partial View you will right-click on the folder where you want that Partial View to be created. Since we want our “LogIn Widget” to be able to be used anywhere, we’ll Right-Click on the \Views\Shared folder, choose “Add and then “View”.

Note the sections indicated in the image above.

I chose a name that begins with an underscore (I don’t want this partial view to ever be rendered directly) and ends with the word “partial” so that I can tell at a glance which of my views are “full” views and which are partial.

In addition I select the check box that instructs the wizard to create a partial view.

Once I complete the wizard my

Views\Shared folder will contain a file named _LoginBoxPartial.cshtml

Next, I need to move two bits of code from my site’s _Layout.cshtml page.

  • The MOdel declaration at the very top.
  • The conditional markup that we put in the _Layout file to create the LogIn or LogOut box, depending on the user’s state of authentication.

 The complete code of our partial view (_LoginBoxPartial.cshtml) loosk like this:



@model ContosoKarateMVC.Models.LogOnModel
@if (!User.Identity.IsAuthenticated)
{
    using (Html.BeginForm('LogOn', 'Account', FormMethod.Post))
    {
        <div class='editor-label'>
            @Html.LabelFor(m => m.UserName)
        </div>
        <div class='editor-field'>
            @Html.TextBoxFor(m => m.UserName)
            @Html.ValidationMessageFor(m => m.UserName)
        </div>
        <div class='editor-label'>
            @Html.LabelFor(m => m.Password)
        </div>
        <div class='editor-field'>
            @Html.PasswordFor(m => m.Password)
            @Html.ValidationMessageFor(m => m.Password)
        </div>
        <div class='editor-label'>
            @Html.CheckBoxFor(m => m.RememberMe)
            @Html.LabelFor(m => m.RememberMe)
        </div>
        <span class='style-button-wrapper'>
            <span class='style-button-l'> </span>
            <span class='style-button-r'> </span>
            <input type='submit' name='Submit' class='style-button'
			       value='Login' />
        </span>
        <hr />
        <ul>
            <li>
		@Html.ActionLink('Create an Account.', 'Register', 'Account')
	    </li>
        </ul>
    }
}
else
{
    using (Html.BeginForm('LogOff', 'Account', FormMethod.Post))
    {
        <span class='style-button-wrapper'>
            <span class='style-button-l'> </span>
            <span class='style-button-r'> </span>
            <input type='submit' name='Submit' class='style-button'
			                     value='Logoff' />
        </span>
    }
}

Then we just need to insert a call to render our partial view in the same location as when the markup was in-line in the Layout file.


@{ Html.RenderPartial('_LoginBoxPartial'); }

Now the Views that derive from our _Layout.cshtml page are free to use whatever model they desire and our LogIn feature will still work.

What’s more, we can reuse the Partial View anywhere in our project.

Note: I’m intentionally not posting a like to the source code (you can easily change the source from the prior post.)

In my NEXT post I’ll illustrate a more complex use of “Widgetry” and I will post the code at that time.


Adding a site wide Log In Features to an ASP.NET MVC Web Site.

Having fitted the theme generated for the Contoso Karate Web Sites (see the previous posts in this series) it’s time to start adding functionality to the template.

If you’re new to ASP.NET MVC, let me take this opportunity to encourage you to stick with it. Much is different and sometimes this makes things especially frustrating because not only do we have to learn new things, but the new things work quite differently than we expect based on our previous experience.

Be tenacious, it’s worth it.

Here is our first feature scenario. My Contoso Karate site will have a “portal” feel to it. The default ASP.NET MVC Internet Application template has a separate page for the user to use to authenticate (Log In) but I want the user to be able to log in from any page in my website.

It’s very common for web sites to have a “Log In” widget in the side bar of their theme, like this:

I want the user to be able to Log In by entering their User Name and Password right here on the Home page, or any page in the site that uses the default page template.

To do this in a functionally complete way I need to provide for several behavioral considerations.

  • The user does not yet have an account on the site and needs to create one.
  • The user submits the form without entering the required User Name and Password.
  • The user fills out the form but the user name and password to not match any in the authentication database.
  • The user entered a valid user name and password and is authenticated when the user clicks the submit button.

In the last case, it doesn’t make sense to continue to show a Log-In feature after the user successfully logs in so we should conditionally display a Log-Out option is the current user is authenticated.

ASP.NET WebForms developers have traditionally been bound by the restriction of a single HTML form to each .ASPX page. (Though technically there are ways around this issue and the server-side execution model for user interface element events made this more or less irrelevant.)

While ASP.NET WebForms abstracts the “nature” of World Wide Web applications, ASP.NET MVC embraces it.

An ASP.NET MVC View can contain any number of html forms and each form’s action attribute can submit to any controller and action (and http method) that we need.

So to create the Log-In feature in the right column of our template (_Layout.cshtml) we will insert an html form object. We will do this using the @Html helper object.


using (Html.BeginForm('LogOn', 'Account', FormMethod.Post))
{
   <div class='editor-label'>
      @Html.LabelFor(m => m.UserName)
   </div>
   <div class='editor-field'>
      @Html.TextBoxFor(m => m.UserName)
      @Html.ValidationMessageFor(m => m.UserName)
   </div>
   <div class='editor-label'>
      @Html.LabelFor(m => m.Password)
   </div>
   <div class='editor-field'>
      @Html.PasswordFor(m => m.Password)
      @Html.ValidationMessageFor(m => m.Password)
   </div>
   <div class='editor-label'>
      @Html.CheckBoxFor(m => m.RememberMe)
      @Html.LabelFor(m => m.RememberMe)
   </div>
   <span class='style-button-wrapper'>
      <span class='style-button-l'> </span>
      <span class='style-button-r'> </span>
      <input type='submit' name='Submit' class='style-button'
         value='Login' />
   </span>
   <hr />
   <ul>
      <li>
    @Html.ActionLink('Create an Account.', 'Register', 'Account')
      </li>
   </ul>
}

Notice that the form labels and fields are referencing a data model (m.UserName). The model is the LogonModel that we get by virtue of starting our project from the default ASP.NET MVC Internet template.
Read the rest of this entry »

Finding Videos, Tutorials, etc. on the ASP.NET Web Site

Many folks have emailed me in recent weeks trying to find some of my old videos or tutorials.

The ASP.NET Web Site has been undergoing a series of incremental improvements and the site management team is working hard to improve the experience and expose all of the available learning resources. While they’re continuing the “findability” work, here is a list of end-points on the ASP.NET Web site that might help you find the training materials that you are looking for.


Videos:



Tutorials:


Pages:


A few more: :


Complete www.ASP.NET Site Map : http://www.asp.net/sitemap

Contoso Karate MVC – Migrating the Theme from WebMatrix

I’ve been a bit slow doing getting all the Contoso Karate Sites that I want to build off the ground.

A couple of weeks ago I started posting about Contoso Karate WebMatrtix [ read HERE ]

To get started with the MVC version, the first thing that I needed to do was to get the theme implemented.

So, I created an ASP.NET MVC site using the default ASP.NET MVC template.

Then I took the markup from the _SiteLayout.cshtml page from my Contoso Karate Web Matrix site and copied it to the _Lyout.cshtlm page

When I first ran (F5) the site in Visual Studio – I get a pleasant surprise :

There was only one change that I needed to make.

Since there is no 1-to-1 relationship between physical endpoints and urls, the can “view” can be requested using different URLs

ie: http://localhost/ & http://localhost/home will result in the same view being rendered.

So I changed resource references (images, etc) in my view to use the magic “HRef” helper.

- @Href(“~/Content/Images”)

You can learn more about the ASP.NET Razor Syntax [ HERE ]

You  can download the Runnable Contoso Karate MVC Theme [ HERE ]

Unobtrusive JavaScript in your ASP.NET pages.

One of the fundamental premises of ASP.NET is the “separation of concerns”. In ASP.NET WebForms Code and Markup go in separate files by default (.aspx / .aspx.cs). In ASP.NET MVC concern isolation is innate to the MVC convention. It therefore only makes sense to apply the same organizational construct to our use of JavaScript, especially as we federate more and more logic to the client side of our applications (meaning the browser.)

I’ve adopted  the practice of “Unobtrusive JavaScript” that appears below. FOr the sake of simplicity I’ve created this without using the standard WebForms template.

Lets suppose I have a page and I want to implement some jQuery / jQuery UI  features. Given this page …

I want to be able to drag & drop ….

And resize it ….

And I wanted to use jQuery UI features like a Pop-Up Calendar Picker.

Read the rest of this entry »

Calling Web Service Page Methods with jQuery

A “Web Service”, according to Wikipedia, is any software that is meant to provide computer to computer communication but is typcally comveyed using HTTP.

Just with the Microsoft Development stack there are lots of ways to expose application logic via HTTP.

  • ASMX
  • WCF
  • CSHTML
  • MVC
  • ASHX (ASP.NET Handler)
  • etc..

As we increase our client side user experience we will certainly be adding cient side behaviors with JavaScript, CSS, and in the future HTML5.

As we add dynamic behavior to our web application user interfaces, we’ll be updating the browser stsate with data retrieved by our client side code.

Often , the server side logic that will delivger this code will have no contextual value outside the “Web Page” that calls it.

Enter ASP.NET Page Methods. “Page Methods” live inside an ASP.NET page. They are callable via JavaScript and therefore require no seperate file, endpoint or infrastructure.

Since I (and many of you) have adopted jQuery as your client side development model, and since Microsoft has officially embraced jQuery, I’ve been moving all my new AJAX code to jQuery.

Since a first stab at calling page methods using jQuery syntax might be a bit tricky, I”ve created this demo.

Joel Carlson blogged a sample using an interesting Page Method Factory and I’m using that method (and code) in this demo.

Starting with the standard ASP.NET Web Forms web site template I’ve addede two page methods, one that is “Read Only” (no parameters) and one that sends data and recieves a return value.
Read the rest of this entry »

ContosoKarate WM – Site Registration

I started building ContosoKarate (WebMatrix) by creating a site using the default WebMatrix Default Site Template.

The default template includes a collection of account related pages.

After modifying the _SiteLayout.cshtml the Register.cshtml looked pretty good.

So there are two things I need to do.

  1. Enable Captcha
  2. Make the formatting pretty.

First, I modified the Login Box markup to include a link to the Register.cshtml page.

<ul>
   <li><a href='#'>Forgot your password?</a></li>
   <li><a href='#'>Forgot your username?</a></li>
   <li><a href='@Href('~/Account/Register.cshtml')' /'>
          Create an account</a></li>
 </ul>

So I did a bit of clean up in the formatting and lined up form fields using a table. I know, I know – but for something this simple a table is perfect and easy.

Next, next enable Re-Captcha. To do this we’ll need to use the WebMatrix Package Manager (which is a front end to NuGet) to download and install some of the basic WebMatrix Razor Helpers.

Before we install he Re-Captcha Helper itself, we’ll need a Re-Captcha Key.

You can get one by going here https://www.google.com/recaptcha/admin/create and following the steps as in the screen shots below.

Save the ReCaptcha keys and start your WebMatrix application then add _Admin to the url in the browser.

ie: http://localhost:9999/_Admin

Read the rest of this entry »

ContosoKarate (WM) – The HTML Theme and ASP.NET Web Pages Integration

Monday I posted that I was starting a series of demo applications [ Read HERE ]

Please keep the suggestions and comments coming.

I’ve been asked about the theme for the site.

Since I have NO artistic ability myself ad I have no budget to hire a designer, I purchased Artisteer (with my own money !)

Artisteer is an interesting tool. Not perfect, but well worth the money for me.

For the “aesthetically challenged” like mem it offer complete theme suggestions and then you can have the tool suggest design changes on a section by section basis.

If you explore the tool you find that you can have a pretty detailed control over the look of your design.

I wanted a pretty standard “portal” style design to start with so I added a custom background and header graphic and settles on this.

Since I’m using a generated theme, in the future I’ll see how hard it will be to try to “plug” in theme variations.

Next, I needed to separate the UI “frame” into a template and the core for the default page into the Default.cshtml page

I’ve done this and formatted the markup. There is still lots to do with the Template but those details will take care of themselves as features get implemented.

The first bit of functionality we need to add is a customized site registration.

I doubt the state of the code would be useful to anyone at this point so I won’t bother to post it but if anyone wants it just email me and I’ll send it to you.

If you are new to WebMatrix of haven’t wrapped your head around PageTemplates yet you can find that and lots of other info [ HERE ]

ASP.NET How-Do-I Video Archive

I’ve been seeing a rise in inbound searches from Google and Bing of people looking for “Joe Stagner Videos”.

The ASP.NET web site team has been doing a lot of reorganizing on the www.asp.net web site and some of the older videos, while still there, are not as easy to find. (They need to make room for the “new” stuff.)

So I’ve started to index my ASP.NET, Microsoft Ajax, and Ajax Control Toolkit Videos here.

You can find them using the Video menu item at the top of my blog or the Videos menu to the right side.

I’ll try to add some every night until I’ve got them all.

Hopefully this will make them easier to find.

Beginning the Contoso Karate WebMatrix Sample App

Today I began work on a new Sample Application called Contoso Karate

My proposed “design” is as follows:

The idea will be to create a production ready web site that represents your kids Karate School.

So, not a big production B2B or B2C Ecommerce site but still something with nice features, community and social functionality.

I intend to build the WebMatrix Version first and then perhaps an ASP.NET MVC 3 version. (Maybe even a MODERN WebForms version if there is interest.)

So, please take a moment to comment below on the features, methods, etc that you would like to see in a learning application with this context.

My goal is that folks will be able to use this to learn Web Site Development with Microsoft WebMatrix or modify the application to host any “club” based web site (Kids Soccer team, bowling league, etc.)

THANKS

jQuery Confirm Buttons and Dialogs for ASP.NET

The ASP.NET Ajax Control Toolkit includes an “Confirm Button” control extender.
In this series I’ve been demonstrating ways to implement the features of the MS Ajax Toolkit with jQuery and in this post I’ll address the “Confirm Button Extender”.
You might think that doing this is so trivial that it wouldn’t warrant a blog post but there is more to it that you might guess at first glance.
In ASP.NET WebForms there is a definite abstraction of the underlying web application mechanics and, for the purposes of this subject there some issues we must consider.
  1. By default, ASP.NET WebForms is a SERVER side programming model and therefore all UI elements (ASP.NET Controls) with user interactions are assumed to have server-side logic.
  2. We are integrating Client AND Server Development Models.
  3. An ASPX (Web Forms) page is assumed to contain only ONE HTML form. (Though we can use advanced manual techniques to bypass this limitation)
  4. Given the above items 1 & 3, all <asp:button> controls render as HTML Submit elements.
So what does that mean ?
HTML actually has three button types :
  • <INPUT TYPE=BUTTON> // A button with a click event.
  • <INPUT TYPE=SUBMIT> // A button whose click posts the html form
  • <INPUT TYPE=RESET> // A button that causes form fields to be reset
So, ASP.NET Buttons all render to HTML SUBMIT buttons.
We can divide button triggered dialogs into two groups:
  • Ones that display something but have no need to SUBMIT The form
  • Ones that take user input and MIGHT submit the form.
Perhaps the most straight forward way to implement both of these categories of button click dialogs is to use input type=”button” for all our buttons and programmatically submit the form when appropriate.
I’ve created a collection on customized buttons with OnClick dialogs:
Each of these will implement different usages of the jQuery.Alert plugin you can find [ HERE ]
The first button is wired to an information only dialog that will display for (in our case) 3 seconds.
Lets look at the markup, the CSS and the page specific JavaScript and then we’ll enumerate the rest of the button behaviors.
The Markup looks like this :

<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
         AutoEventWireup='true' CodeFile='Default.aspx.cs'
		 Inherits='_Default' %>

<asp:Content ID='HeaderContent' runat='server'
             ContentPlaceHolderID='HeadContent'>
<link href='Styles/jqdialog.css' rel='stylesheet' type='text/css' />
</asp:Content>
<asp:Content ID='BodyContent' runat='server'
             ContentPlaceHolderID='MainContent'>
<br />
<button ID='btnotify' type='button' class='CustomButton'>
        Notification Popup
</button><br /><br />
<button ID='btalert' type='button' class='CustomButton'>
        Alert Popup
</button><br /><br />
<button ID='btconfirm' type='button' class='CustomButton'>
        Confim Dialog
</button><br /><br />
<button ID='btprompt' type='button' class='CustomButton'>
        Input Prompt
</button><br /><br />
<button id='btcontent' type='button' class='CustomButton'>
        Any Custom Content
</button><br /><br />

<script src='http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.js'
        type='text/javascript'></script>
<script src='Scripts/jqdialog.min.js' type='text/javascript'></script>
<script src='Scripts/jQueryDialogs.js' type='text/javascript'></script>
</asp:Content>

Note that the concise markup does not reflect the rich functionality associated with the buttons.
The CSS class designation [class="CustomButton"] is responsible for the styled appearance of the buttons but not the behavior. Often when using jQuery we will use a data attribute or a class identifier to connect the desired jQuery code to the HTML elements but since button dialogs are likely to be very specific (one dialog for each button), the jQuery behaviors in this demo will be connection via the button element ID.
The CSS is as follows. Note that the Custom Button class is at the bottom and all the rest of the CSS defines the visuals for the various dialogs. In your app you would only include the classes that you use on your pages.

Using jQuery for ASP.NET Styled DropDown

The ASP.NET Ajax Control Toolkit includes an “Styled Dropdown” control extender.
In this series I’ve been demonstrating ways to implement the features of the MS Ajax Toolkit with jQuery.

HTML has the <select> element for drop down lists and ASP.NET has the DropDownList control, but the styling is pretty plain.

Luckily, we can us a jQuery plugin to change the styling of both <select> and <asp:DropDownList>
By default the DropDownList looks like this:

While this works fine we might want to style the DropDown to match our UI of to obviate the context of our dropdown.

You can find the plugin we will use here:
The custom styling will consist of a combination css and the following background image.

The page markup is as follows:

<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
         AutoEventWireup='true' CodeFile='Default.aspx.cs'
		 Inherits='_Default' %>

<asp:Content ID='HeaderContent' runat='server'
             ContentPlaceHolderID='HeadContent'>
    <link href='Styles/Selectbox.css' rel='stylesheet' type='text/css' />
	<script src='http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.js'
            type='text/javascript' charset='utf-8'></script>
	<script type='text/javascript' src='Scripts/jquery.selectbox-0.5.js'>
	</script>
    <script src='Scripts/PageScript.js' type='text/javascript'></script>
</asp:Content>
<asp:Content ID='BodyContent' runat='server'
             ContentPlaceHolderID='MainContent'>
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit
        <a href='http://www.asp.net' title='ASP.NET Website'>www.asp.net</a>.
    </p>

    <p>
    <asp:DropDownList runat='server' name='Items' id='Items'
                      class='StyledDD' ClientIDMode='Static'>
      <asp:ListItem>One</asp:ListItem>
      <asp:ListItem>Two</asp:ListItem>
      <asp:ListItem>Three</asp:ListItem>
      <asp:ListItem>Four</asp:ListItem>
    </asp:DropDownList>
    </p>
</asp:Content>

Read the rest of this entry »

Using jQuery for ASP.NET Textbox Autocomplete

The ASP.NET Ajax Control Toolkit includes an “Autocomplete Extender“.

In this series I’ve been demonstrating ways to implement the features of the MS Ajax Toolkit with jQuery.

jQuery UI makes “AutoComplete” very straight forward (Read the plugin spec here.)

Here is the behavior.

After the user enters 2 or more characters, then the UI starts to suggest values for the textbox.

In the case fo the jQuery UI Autocomplete plugin, the data can come from inside the page’s Document Object Model (DOM) or from a JavaScript callable web service.

For small data sets you may want to just send all the possible values to the browser with the rest of the page but AutoSuggest fields are most helpful when the number of possible value choices are too numerous to fit in a page’s dropdown control.

In this case, supplying the values via a service method is your choice and that’s what we’ll do in our example.

After creating a new website using the default ASP.NET Web Site Template, I’ll include a jQuery UI template CSS file and 3 JavaScript files.

  • jQuery
  • jQuery UI
  • a custom JavaScript file that contains my page specific code.

Then I’ll add an ASP.NET TextBox filed and associated label for the user to enter an email address in.

The markup for my default.aspx page is as follows:


<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
         AutoEventWireup='true' CodeFile='Default.aspx.cs'
		                        Inherits='_Default' %>

<asp:Content ID='HeaderContent' runat='server'
             ContentPlaceHolderID='HeadContent'>
<link href='http://ajax.aspnetcdn.com/ajax/jquery.ui/
                   1.8.10/themes/redmond/jquery-ui.css'
      rel='stylesheet' type='text/css'/>

</asp:Content>
<asp:Content ID='BodyContent' runat='server'
                              ContentPlaceHolderID='MainContent'>
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit
        <a href='http://www.asp.net' title='ASP.NET Website'>www.asp.net</a>.
    </p>
    <hr /><br />

    <div>
            <label for='tbAuto'>Enter Email: </label>
             <asp:TextBox ID='tbAuto' class='autosuggest' runat='server'>
             </asp:TextBox>
    </div>
    <script type='text/javascript'
            src='http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.js'>
    </script>
    <script type='text/javascript'
     src='http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/jquery-ui.js'>
    </script>
    <script src='Scripts/PageScript.js' type='text/javascript'></script>
</asp:Content>

Next we need a service that will take a few characters of string as in input argument and return a collection of emaill addresses that match the beginning characters that the user entered.

SO, I’ll add an .ASMX service called EmployeeList.asmx

The service codebehind looks like this:



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

[WebService(Namespace = &quot;http://tempuri.org/&quot;)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class EmployeeList : System.Web.Services.WebService
{
  [WebMethod]
    public List GetEmailSuggestions(string mail)
    {
    var emp = new Employee();
    var suggestionList = emp.GetEmployeeList()
    .Where(m => m.Email.ToLower().StartsWith(mail.ToLower()));
        return suggestionList.ToList();
    }
}

If you are new to service programming in ASP.NET you will note the [WebMethod] attribute on the GetMailSuggestions method will cause the method to be exposed via HTTP and the class itself is decorated with the [ScriptService] attribute which will make the class callable my JavaScript and provide facilities like JavaScript proxy generation.
Read the rest of this entry »

A jQuery Combo Box for ASP.NET

The ASP.NET Ajax Control Toolkit contains a Combo Box Control.

Since I’m posting a series on replacing Ajax Control Toolkit functions with jQuery, in this post we’ll use a jQuery plugin to DropDown control into a slick ComboBox.

Here is the experience :

You can click on the down arrow and see the entire list. Combo boxes excel in scenarios where there are MANY items in the selection set. (Usually to many to be seen without scrolling.

So  in a Combo Box we can type to filter the selection list based on what is types.

Since this is an ASP.NET control, when we submit the page we can access the selected value in our code-behind.

I’m building this using a jQuery Plugin called Hyjack.

[ Get it HERE ]

As with most jQuery plugins, Hyjack is simple to use.

NOTE: the code below includes all JavaScript code at the TOP of the page, uses in line JavaScript, and statically includes the jQuery library. This is done only for illustrative simplicity and is NOT best practice. Please find a variety of best practices information in the posts HERE.

Here is the complete page markup:



<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
         AutoEventWireup='true' CodeBehind='Default.aspx.cs'
         Inherits='jQueryComboBox._Default' %>

<asp:Content ID='HeaderContent' runat='server'
             ContentPlaceHolderID='HeadContent'>
    <link href='Styles/hyjack.css' rel='stylesheet' type='text/css' />
    <script src='Scripts/jquery-1.4.1-vsdoc.js' type='text/javascript'>
	</script>
    <script src='Scripts/jquery.hyjack.select.js' type='text/javascript'>
	</script>
    <script type='text/javascript'>

		$(function () {

			// Hyjack Onload with all defaults
			$('.hyjack').hyjack_select();

			/* Multiple CLASS with customization

			$('.hyjack').hyjack_select({        // Defaults
			ddImage: 'image/of/arrow.png',      // arrow_down.png
			ddCancel: 'image/of/cancel.png',    // cancel.png
			ddImageClass: 'class_of_arrow',     // hjsel_ddImage
			ddCancelClass: 'class_of_cancel',   // hjsel_ddCancel
			emptyMessage: 'No Items Message',   // No Items to Display
			restrictSearch: false/true,         // false
			offset: 12                          // false
			});

			*/
        });
	</script>

</asp:Content>
<asp:Content ID='BodyContent' runat='server'
             ContentPlaceHolderID='MainContent'>
    <h2>
        Select Your State
    </h2>
    <br /><br />
    <asp:DropDownList ID='DDPickState'  class='hyjack' runat='server'>
        <asp:ListItem Value='AL'>Alabama</asp:ListItem>
        <asp:ListItem Value='AK'>Alaska</asp:ListItem>
        <asp:ListItem Value='AZ'>Arizona</asp:ListItem>
        <asp:ListItem Value='AR'>Arkansas</asp:ListItem>
        <asp:ListItem Value='CA'>California</asp:ListItem>
        <asp:ListItem Value='CO'>Colorado</asp:ListItem>
        <asp:ListItem Value='CT'>Connecticut</asp:ListItem>
        <asp:ListItem Value='DC'>District of Columbia</asp:ListItem>
        <asp:ListItem Value='DE'>Delaware</asp:ListItem>
        <asp:ListItem Value='FL'>Florida</asp:ListItem>
        <asp:ListItem Value='GA'>Georgia</asp:ListItem>
        <asp:ListItem Value='HI'>Hawaii</asp:ListItem>
        <asp:ListItem Value='ID'>Idaho</asp:ListItem>
        <asp:ListItem Value='IL'>Illinois</asp:ListItem>
        <asp:ListItem Value='IN'>Indiana</asp:ListItem>
        <asp:ListItem Value='IA'>Iowa</asp:ListItem>
        <asp:ListItem Value='KS'>Kansas</asp:ListItem>
        <asp:ListItem Value='KY'>Kentucky</asp:ListItem>
        <asp:ListItem Value='LA'>Louisiana</asp:ListItem>
        <asp:ListItem Value='ME'>Maine</asp:ListItem>
        <asp:ListItem Value='MD'>Maryland</asp:ListItem>
        <asp:ListItem Value='MA'>Massachusetts</asp:ListItem>
        <asp:ListItem Value='MI'>Michigan</asp:ListItem>
        <asp:ListItem Value='MN'>Minnesota</asp:ListItem>
        <asp:ListItem Value='MS'>Mississippi</asp:ListItem>
        <asp:ListItem Value='MO'>Missouri</asp:ListItem>
        <asp:ListItem Value='MT'>Montana</asp:ListItem>
        <asp:ListItem Value='NE'>Nebraska</asp:ListItem>
        <asp:ListItem Value='NV'>Nevada</asp:ListItem>
        <asp:ListItem Value='NH'>New Hampshire</asp:ListItem>
        <asp:ListItem Value='NJ'>New Jersey</asp:ListItem>
        <asp:ListItem Value='NM'>New Mexico</asp:ListItem>
        <asp:ListItem Value='NY'>New York</asp:ListItem>
        <asp:ListItem Value='NC'>North Carolina</asp:ListItem>
        <asp:ListItem Value='ND'>North Dakota</asp:ListItem>
        <asp:ListItem Value='OH'>Ohio</asp:ListItem>
        <asp:ListItem Value='OK'>Oklahoma</asp:ListItem>
        <asp:ListItem Value='OR'>Oregon</asp:ListItem>
        <asp:ListItem Value='PA'>Pennsylvania</asp:ListItem>
        <asp:ListItem Value='RI'>Rhode Island</asp:ListItem>
        <asp:ListItem Value='SC'>South Carolina</asp:ListItem>
        <asp:ListItem Value='SD'>South Dakota</asp:ListItem>
        <asp:ListItem Value='TN'>Tennessee</asp:ListItem>
        <asp:ListItem Value='TX'>Texas</asp:ListItem>
        <asp:ListItem Value='UT'>Utah</asp:ListItem>
        <asp:ListItem Value='VT'>Vermont</asp:ListItem>
        <asp:ListItem Value='VA'>Virginia</asp:ListItem>
        <asp:ListItem Value='WA'>Washington</asp:ListItem>
        <asp:ListItem Value='WV'>West Virginia</asp:ListItem>
        <asp:ListItem Value='WI'>Wisconsin</asp:ListItem>
        <asp:ListItem Value='WY'>Wyoming</asp:ListItem>
    </asp:DropDownList>
    <br /><br />
    <asp:Button ID='ButtonSubmit' runat='server' Text='Submit'
        onclick='ButtonSubmit_Click' /><br /><br />
    <asp:Label ID='LabelResult' runat='server' Text=''></asp:Label>
</asp:Content>

And here is the code behind.


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

namespace jQueryComboBox
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            LabelResult.Text = &quot;The State You Picked is : &quot; +
                                DDPickState.SelectedValue.ToString();
        }
    }
}

I’ve statically defined the list items but since the parrent control is an ASP.NET Drop Down, you could easily bind the items list to a data source of your choosing.

[ You can download the code above HERE ]


Improving the Code – jQuery Modal Dialog in an ASP.NET page.

Last month I did this post on creating a jQuery Modal Dialog in an ASP.NET page.

My friend Jose Guay emailed me to say “hey Joe – nice sample but why not really wire things up the jQuery way ?”

Jose’s right so here it is.

The OLD markup looked like this:


<asp:Content ID='HeaderContent' runat='server'
             ContentPlaceHolderID='HeadContent'>
    <link href='Scripts/fancybox/jquery.fancybox-1.3.4.css'
          rel='stylesheet' type='text/css' />
    <script src='Scripts/fancybox/jquery.fancybox-1.3.4.js'
	        type='text/javascript'>
    </script>
    <script src='Scripts/tos.js' type='text/javascript'></script>
</asp:Content>
<asp:Content ID='BodyContent' runat='server'
             ContentPlaceHolderID='MainContent'>
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit
        <a href='http://www.asp.net' title='ASP.NET Website'>www.asp.net</a>.
    </p>
    <div id='content'>
	<h1>Join Our Community</h1>
	<hr />
	Lorem ipsum dolor sit amet, consectetur adipiscing elit. <br /><br />
	Etiam quis mi eu elit tempor facilisis id et neque.
	Nulla sit amet sem sapien. Vestibulum imperdiet porta ante ac ornare.
	Nulla et lorem eu nibh adipiscing ultricies nec at lacus. Cras laoreet
	ultricies sem, at blandit mi eleifend aliquam. Nunc enim ipsum,
	vehicula non pretium varius, cursus ac tortor. Vivamus fringilla
	laoreet. Quisque ultrices sodales orci, quis rhoncus justo auctor in.
	Phasellus dui eros, bibendum eu feugiat ornare, faucibus eu mi. Nunc
	aliquet tempus sem, id aliquam diam varius ac.
    <hr />
    <br />
    <!-- Modal Dialog -->
    <a id='tos' href='#serviceterms'
	   title='You must agree with our tems of service.'>
       Click HERE to Agree to our Terms
    </a>
    <div style='display: none;'>
	<div id='serviceterms' style='width:440px;height:250px;overflow:auto;'>
		Lorem ipsum dolor sit amet, consectetur adipiscing elit. <br /><br />
		Etiam quis mi eu elit tempor facilisis id et neque.
		Nulla sit amet sem sapien. Vestibulum imperdiet porta ante ac ornare.
		Nulla et lorem eu nibh adipiscing ultricies nec at lacus. Cras
		ultricies sem, at blandit mi eleifend aliquam. Nunc enim ipsum,
		vehicula non pretium varius, cursus ac tortor. Vivamus fringilla
		laoreet. Quisque ultrices sodales orci, quis rhoncus justo auctor in.
		Phasellus dui eros, bibendum eu feugiat ornare, faucibus eu mi. Nunc
		aliquet tempus sem, id aliquam diam varius ac.
		<br /><br /><hr />
		<input type='button' value='Yes' onclick='ToS_Agree()' />&nbsp;&nbsp;
		<input type='button' value='No' onclick='ToS_NotAgree()' />
	</div>
	</div>
    <br /><br />

    <asp:Button ID='SubmitButton' runat='server' Text='Submit Form'
	            Enabled='False'
                ClientIDMode='Static' onclick='SubmitButton_Click' />
        <br /><br />
    <asp:Label ID='LabelResult' runat='server' Text=''></asp:Label>

</div>
</asp:Content>

And the included JavaScript (tos.js) looked like this:


$(document).ready(function () {

    $('#tos').fancybox({
    	'titlePosition': 'inside',
    	'modal': 'true',
    	'transitionIn': 'none',
    	'transitionOut': 'none'
    });
});

function ToS_Agree() {
    $('#SubmitButton').removeAttr('disabled');
    $.fancybox.close();
}

function ToS_NotAgree() {
    $('#SubmitButton').attr('disabled', 'disabled');
    $.fancybox.close();
}

So, I am sort of mixing metaphor’s here.

Lets look at a better way.

Read the rest of this entry »

Microsoft Application Request Routing (ARR) 2.5 released.

Overview:
Application Request Routing v2.5 improves the performance and the scalability of ARR in its disk caching scenarios.   In addition to fully incorporating the enhancements described in KB 2406763, it includes additional optimizations to balance the use of memory and disk caching.   The use of this release is especially recommended to those who are extensively using the disk caching features in ARR.

Download ARRv2.5 from:
ARRv2.5 is available only via Web Platform Installer (WebPI). Download ARRv2.5 via WebPI here.
The download pages for ARRv2.5 can be found at:

  • Microsoft Application Request Routing Version 2.5 (x86) here.
  • Microsoft Application Request Routing Version 2.5 (x64) here.

Features:
ARRv2.5 is mostly a performance and scalability focused release, so there is little functional difference between ARRv2.1 and ARRv2.5.   However, when it comes to disk caching performance and scalability, including latency improvements, there are significant differences between ARRv2.1 and ARRv2.5.
One functional change that is worth mentioning is the ability to set the client affinity cookie on the main domain name.   This particularly interesting if the site has multiple sub-domains, such as images.contoso.com, members.contoso.com and so on.   On such sites, in order to maintain client affinity across sub-domains, the client affinity can be set on the main domain, .contoso.com.

Support:
ARRv2.5 is a fully release version and therefore the support is provided via Microsoft Support.   In addition, the ARR forum is a great place to connect with the community, including the ARR product team.

A jQuery Color Picker for ASP.NET Apps

There are lots of “ColorPickers” out there.

I liked the way mColorPicker worked, though did make some minor modifications to the source for this demo.

Just picking a color is a bit boring so I’m adding a bit of spice.

  1. After selecting a new color client side I use that color to change the background color of the current page (no postback)
  2. Upon Server PostBack we echo the hex value of the selected color.

Here is the experience.


Note the TextBox which is an ASP.NET TextBox Server Control and the multi-color icon nect to the text box.

Clicking on the color icon displays the ColorPicker.

As you hover over the different colors the hex value of the current color is displayed in the TextBox and the TextBox background color is set to that color as well.

The “Set Color” Button is an HTML input element (Client Side) and when you click it, the background color of the page is set to the newly selected color (as you can see in the image above.)

The “Submit Form” Button is an ASP.NET Server Side Button Control and when you click it the form is posted back to the server.

The new color value is retrieved from the Color Text Box and is inserted into the Label control at the bottom of the page.

Note that after the page is submitted (and therefore redrawn) the page’s background revert to its default color. If you wanted to make the selected color permanent we would need to dynamically load the background color from somewhere and save the updated color whenever the user selected a new one.
Feel free to give that a try on your own if you need such a feature.

To implement this, begin by loading the jQuery and jQueryUI libraries.

I’ll do this in my MasterPage and load them from the Microsoft CDN (which means you’ll have to modify the following code if want to run this on a machine that is not connected to the internet.)


<script type="text/javascript"
        src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.js"></script>
<script type="text/javascript"
        src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/jquery-ui.js">

The actual page markup look like this.
Read the rest of this entry »

A Collapsible Content Area Using jQuery UI

As I’m going though all of the Ajax Control Toolkit Controls and demonstrating ways to replace the behaviors with client side technology (JavaScript / jQuery) I can’t help but wonder if some of them are too simple to bother with but since I committed to blogging one example for each control in the ACT, I will continue and then move on to more “Ajax and UI Patterns” content.

I did a previous post on implementing an Accordion style Content Container using jQueryUI and thereby replacing the Accordion Control in the Ajax Control Toolkit.

I suppose you could use the Accurdion method that I demonstrated in that post and only use one accordion section but there is an even easier jQueryUI plugin that you can use. Check put the Simple Collapsible Panel plugin HERE.

If you have tried a number of jQuery UI Plugins using the default ASP.NET Web Site Template and ASP.NET Server controls you have probably discovered that it’s possible to discover conflicts.

Lets try it with ths Collapsible Panel Plugin.

We’re going to need jQuery and jQueryUI which I will include as follows.


<asp:Content ID='HeaderContent' runat='server'
             ContentPlaceHolderID='HeadContent'>
<link href='Styles/diQuery-collapsiblePanel.css' rel='stylesheet'
            type='text/css' />
<link href='Styles/jquery-ui-1.8.11.custom.css' rel='stylesheet'
            type='text/css' />
<script src='Scripts/jquery-1.4.1-vsdoc.js' type='text/javascript'>
</script>
<script src='Scripts/ui/jquery-ui-1.8.11.custom.js' type='text/javascript'>
</script>
<script src='Scripts/diQuery-collapsiblePanel.js' type='text/javascript'>
</script>
    <script type='text/javascript'>
            $(document).ready(function() {
                  $('.collapsibleContainer').collapsiblePanel();
              });
    </script>
</asp:Content>

Now, for demo simplicity there are a few things above that you probbaly do not want to do in a production application.

  1. I used the default version of jQuery that is part of the default ASP.NET project template. You should use the LATEST version of jQuery.
  2. You probably want to load jQuery from the Microsoft CDN
  3. You also probbaly want to load jQueryUI from the Microsoft CDN
  4. It’s good practive to put all your JavaScript code in a .js file
  5. Whenever possible you want to reference your JavaScript files from the bottom of your page markup. [ Read HERE ]

Read the rest of this entry »

jQuery Modal Dialog in an ASP.NET page.

Modal dialogs are a cornerstone of modern application user interface design and web applications don’t differ from any other type of application UI in this regard.
I did a JavaScript & jQuery Modal Dialogs Roundup a little while back and though I listed a bunch, readers even added a few more. So, there are lots of options.
People seem to get freaked out about making choices. Personally I like the fact that I have so many options and, in the case of Modal Dialogs for web applications, I can pick one that most closely matches the aesthetics and behaviors that I want for my application.
For this post I’m going to use http://fancybox.net/
Which one YOU choose shouldn’t materially change your implementation strategy since, as I hope is starting to become clear, the tricky part in using these sort of jQuery features is the relationship between client side “stuff (HTML Elements, JavaScript, Data, etc.) and the ASP.NET specific things.
Next lets add the jQuery library to our masterpage.
Normally for demo code I use the static librraies that get added to my site directory by VIsual Studio, but in a prodocution wed site you probbaly want to use the Microsoft CDN.
Like this :

<head runat='server'>
    <title></title>
    <link href='~/Styles/Site.css' rel='stylesheet' type='text/css' />
    <script src='http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.1.js'
            type='text/javascript'></script>
    <asp:ContentPlaceHolder ID='HeadContent' runat='server'>
	</asp:ContentPlaceHolder>
</head>

Why use the CDN you say?
  • The CDN has the latest released versions. The Visual Studio template has the version that was current back when Visual Studio 2010 was released.
  • Many ASP.NET sites use jQuery and load from the Microsoft CDN – the files may already be cached for your user.
  • If if the files are not cached it will likely be a bit faster.
  • Take load of YOUR server and reduce your server’s bandwidth.
The page that will display our Modal Dialog pulls in the FancyBox JavaScript and CSS files as well as our own custom JavaScript file that defines the client behavior we desire.
For learning simplicity I’ve previously implemented our custom JavaScript in-line but in practice, it’s better to abstract or JavaScript.
Now that we are getting familiar with the jQuery basics I’ll be trying to use more “best practices” in the demo code as I continue with the jQuery series.

<asp:Content ID='HeaderContent' runat='server'
             ContentPlaceHolderID='HeadContent'>
    <link href='Scripts/fancybox/jquery.fancybox-1.3.4.css'
          rel='stylesheet' type='text/css' />
    <script src='Scripts/fancybox/jquery.fancybox-1.3.4.js'
	        type='text/javascript'>
    </script>
    <script src='Scripts/tos.js' type='text/javascript'></script>
</asp:Content>

Our scenario is that the Modal Popup is a “Terms of Use” dialog.
Here is our page’s markup.


<asp:Content ID='BodyContent' runat='server'
             ContentPlaceHolderID='MainContent'>
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit
        <a href='http://www.asp.net' title='ASP.NET Website'>www.asp.net</a>.
    </p>
    <div id='content'>
	<h1>Join Our Community</h1>
	<hr />
	Lorem ipsum dolor sit amet, consectetur adipiscing elit. <br /><br />
	Etiam quis mi eu elit tempor facilisis id et neque.
	Nulla sit amet sem sapien. Vestibulum imperdiet porta ante ac ornare.
	Nulla et lorem eu nibh adipiscing ultricies nec at lacus. Cras laoreet
	ultricies sem, at blandit mi eleifend aliquam. Nunc enim ipsum,
	vehicula non pretium varius, cursus ac tortor. Vivamus fringilla congue
	laoreet. Quisque ultrices sodales orci, quis rhoncus justo auctor in.
	Phasellus dui eros, bibendum eu feugiat ornare, faucibus eu mi. Nunc
	aliquet tempus sem, id aliquam diam varius ac.
    <hr />
    <br />
    <!-- Modal Dialog -->
    <a id='tos' href='#serviceterms'
	   title='You must agree with our tems of service.'>
        Click HERE to Agree to our Terms
    </a>
    <div style='display: none;'>
	<div id='serviceterms' style='width:440px;height:250px;overflow:auto;'>
	Lorem ipsum dolor sit amet, consectetur adipiscing elit. <br /><br />
	Etiam quis mi eu elit tempor facilisis id et neque.
	Nulla sit amet sem sapien. Vestibulum imperdiet porta ante ac ornare.
	Nulla et lorem eu nibh adipiscing ultricies nec at lacus. Cras laoreet
	ultricies sem, at blandit mi eleifend aliquam. Nunc enim ipsum,
	vehicula non pretium varius, cursus ac tortor. Vivamus fringilla congue
	laoreet. Quisque ultrices sodales orci, quis rhoncus justo auctor in.
	Phasellus dui eros, bibendum eu feugiat ornare, faucibus eu mi. Nunc
	aliquet tempus sem, id aliquam diam varius ac.
	<br /><br /><hr />
	<input type='button' value='Yes' onclick='ToS_Agree()' />&nbsp;&nbsp;
	<input type='button' value='No' onclick='ToS_NotAgree()' />
	</div>
	    </div>
    <br /><br />

    <asp:Button ID='SubmitButton' runat='server' Text='Submit Form'
	            Enabled='False'
                ClientIDMode='Static' onclick='SubmitButton_Click' />
        <br /><br />
    <asp:Label ID='LabelResult' runat='server' Text=''></asp:Label>

</div>
</asp:Content>

Note the buttons on lines 39 and 40. We want our Modal Dialog to “actionable” in that the user must click YES to accept the terms of service or NO to reject them.
In order to submit the form the user must accept the terms of service. The submit button declared at line 45 is DISABLED by default to the form can’t be submitted.
When the user clicks on the “YES” button inside the Modal Dialog the button will be enabled.
Let’s look at our custom JavaScript.

$(document).ready(function () {

    $('#tos').fancybox({
    	'titlePosition': 'inside',
    	'modal': 'true',
    	'transitionIn': 'none',
    	'transitionOut': 'none'
    });
});

function ToS_Agree() {
    $('#SubmitButton').removeAttr('disabled');
    $.fancybox.close();
}

function ToS_NotAgree() {
    $('#SubmitButton').attr('disabled', 'disabled');
    $.fancybox.close();
}

We also have a bit of C# Code-Behind that does two things.

Using jQuery UI DatePicker in an ASP.NET Application.

The Ajax Control Toolkit contains a Calendar Control.

jQuery UI has an amazing alternative in the DatePicker control.

When it comes to this and all jQueryUI features, do yourself a service and check out the tabs – Overview, Options, Events, Methods, Theming. In the case of the DatePicker control, not only are all the expected events exposed and hookable but the rich Options collection will let you exercise detailed control over the date and UI formatting.

If you’re new to jQuery UI you will note that when you download the jQueryUI you can select one of a collection of preexisting themes.

Let’s begin by walking through the process of getting the jQueryUI library.

Start by hoping over to http://jqueryui.com/

We need to select a theme to use for configuring our jQueryUI download, so click on the “Demos & Documentation” link at the top of the page.

AT the top right corner of the demo area of the page there is drop-down with theme previews. Select a theme to try and then run the demos to see how that particular feature looks using the selected theme.

In our case we’ll select the Redmond Theme.

Now, go to the download page.

Read the rest of this entry »

Podcast- Erik Porter – ASP.NET Pages (WebMatrix) & Razor

Erik Porter is a PM in Microsoft Web Platform and Tools Group and responsible for ASP.NET Web Pages (WebMatrix) and the Razor Syntax.

In this episode, we discuss the success of WebMatrix and Razor, What’s New, and What the team is planning to do going forward.

Resources

Listen

Get Microsoft Silverlight

Subscribe

MP3 WMA M4A Zune iPod

Download

3GP File
3GP
iPod File
iPod
MP4 File
MP4
MP3 File
MP3
M4A File
M4A
M4V File
M4V
PSP File
PSP
WMV File
WMV
ZIP File
Zip
WMA File
WMA
Zune File
Zune

ASP.NET Accordions with jQueryUI

Replacing the Ajax Control Toolkit’s Accordion control with jQueryUI

Accordion style containers are a great way to maximize the use of your browser based screen real estate.

Note the UI and behavior of an Accordion Content Control.

The default display looks like this.

Clicking on the second header bar closes the first content area and opens the second.

Some time ago I did a video on using Accordions with the ASP.NET AJAX Control Toolkit. You can check it out here.

The thing about accordion controls is the the content exists in HTML <div> elements which means we can populate them with static markup, server side controls, of even markup retrieved by way of an AJAX service method call and inserted by our client side JavaScript code.

There are many JavaScript libraries and jQuery Plug-Ins that can assist us in implementing an accordion container. In this case I’ll use one of the most popular, the jQueryUI library.

http://jqueryui.com/

jQueryUI is highly configurable as we’re about to see.

First, click the demos link.

Though we’re specifically interested in the Accordion demo, you should take time to look at the other demos to see some of the other things that can be accomplished with jQueryUI.

Note that after you load the Accordion demo you can try different color “themes” by using the themes selector on the left.

When you’ve decided which theme you are interested in using as a starting place you need to download jQueryUI.

Read the rest of this entry »

A collection of ASP.NET Tutorials Cool How Tos (44)

Learn


Web Development 101 using WebMatrix
Web Development 101: Part 1, Getting Started with WebMatrix
Web Development 101: Part 2, Create your first Web Page
Web Development 101: Part 3, Getting some style
Web Development 101: Part 4, Using Layout
Web Development 101: Part 5, Using Data
Web Development 101: Part 6, Creating an Add Data page
Web Development 101: Part 7, Creating an Edit Data Page
Web Development 101: Part 8, Creating a Delete Data page
Web Development 101: Part 9, Deploying your site
Introduction to CSS
Learn HTML: Part 2
Learn HTML: Part 1
Introduction to JavaScript: Part 3 of 3
Introduction to JavaScript: Part 2 of 3
Introduction to JavaScript, Part 1 of 3


How To


Understanding MySQL Errors when installing Web Apps in WebMatrix
Set Up a Simple Theme for Your Website Using WebMatrix
Using the Windows Live Translator API
Using the Bing Maps API
Using Facebook Helpers on your Website
Quickly add other languages to your site using automatic translation
Create and Sell Merchandise with the Zazzle API on your website
Using the Hulu widgets to add TV to your site
Add driving directions to your site with Bing Maps
Add a photo gallery to your website using Lightbox and JavaScript
Improve Your Website Using the WebMatrix SEO Report
Get Started with SEO using WebMatrix
Using the free Bing Translation APIs
Build a Web Site in twenty minutes using WordPress and WebMatrix
Creating forms for your site using EmailMeForm
Use LightBox for beautiful Images on your web site


Walkthroughs


Installing Umbraco with WebMatrix.
Using BlogEngine.NET with WebMatrix
Installing ScrewTurn Wiki using WebMatrix
Getting started with Joomla and WebMatrix
Set Up a Simple Theme for Your Website Using WebMatrix
WebMatrix and Drupal: Build a site in 15 minutes
Using WebMatrix to build a DotNetNuke Application
Settting Up your NopCommerce website using WebMatrix
Installing, Configuring, and Publishing your Umbraco site with WebMatrix
Installing and Publishing Orchard using WebMatrix
Installing and Publishing a WordPress Blog with WebMatrix
Improve Your Website Using the WebMatrix SEO Report


Dynamic Cascading Selection Lists for ASP.NET WebForms with jQuery.

I’ve blogged previously that I’m on a mission to build samples of implementing all the ASP.NET Ajax Control Toolkit Features WITHOUT the Ajax Control Toolkit.

If you’re ever used the Cascading Drop Down control extender in the Ajax Control Toolkit, then you know that it’s syntactically easy to use but a real pain to debug.

You may have also discovered that any JavaScript code that effects the state of an ASP.NET Drop Down Control has it’s influence lost when you submit your form back to the server.

This is due to a collection of tomfoolery that happens under the covers with the Drop Down control as it pertains to ASP.NET View State.

To side step the ViewState complexities, we’ll do all the Cascading Drop Down UI on the client and only use ASP.NET Server controls the minimal amount necessary to easily post our selected values back to the server.

Here is the UI interaction flow that we want.

This is the way that the page renders.

Then the user selects from the list of car Makes.

Note that at this point, ONLY the Car “Makes” list is populated.

We can’t display the models until we know what “Make” the user is interested in.

As a result, the “Models” and “Colors” controls are not even active yet.

After we select a car “Make”, the “Models” Drop Down has been filled with values as the result of an AJAX call to the server that passes the “Make” value as an argument so that the related “Models” can be returned.

The same happens when we select a “Model”.

The colors that the model is available in now appear in the “Colors” Drop Down.

When the user has selected a value in each of the three text boxes and clicks the Submit Button, the ASP.NET’ page’s Code-Behind Retreives the selected values and displays a result message.

There is, however, a but of trickery necessary to make this happen.

First, the Drop-Dwn lists are NOT ASP.NET Server Controls, they are simple HTML <select> elements.

This first one (Makes) is populated with statically defined values but you could populate them from a service call when the page loads if you felt it neccessary.

New car companies don’t come into existance very often, so I don’t think it’s necessary in this case.


    <div id='SelectionContainer' runat='server'>
    <select id='DDListMake' name='DDListMake' style='width: 200px'>
		<option>Select...</option>
		<option value='Ford'>Ford</option>
		<option value='Cadilac'>Cadilac</option>
		<option value='Toyota'>Toyota</option>
		<option value='Jeep'>Jeep</option>
		<option value='Mazda'>Mazda</option>
	</select>
    <asp:HiddenField ID='TextMake' runat='server' ClientIDMode='Static' />
    <br />
    <select id='DDListModels' style='width: 200px' disabled='true'></select>
    <asp:HiddenField ID='TextModel' runat='server' ClientIDMode='Static' />
    <br />
    <select id='DDListColors' style='width: 200px' disabled='true'></select>
    <asp:HiddenField ID='TextColor' runat='server' ClientIDMode='Static' />
    <br /><br />
    <asp:Button ID='ButtonSend' runat='server' Text='Submit Selections'
                onclick='ButtonSend_Click' />
    </div>
    <asp:Label ID='LabelResult' runat='server' Text=''></asp:Label>

Note that the Drop Down Lists are simple HTML Select Elements.

The Button and the Label are ASP.NET controls.

Take special note of the three “Hidden” ASP.NET contol instances.

We will populate these with the values that the user selects in each Drop Down so that we can retrieve those values in our code-behind.

Implementing the simplest possible web service.

The .NET platform is rife with ways to serve up content via HTTP.

We have ASMX, ASPX, ASHX, WCF, MVC Views, all of which could be used to serve non markup data.

Read the rest of this entry »

TextBox Input Watermark using jQuery

The Microsoft Ajax Control Toolkit (ACT) contains a TextBox Watermark control.

I did a sample and video HERE.

I’ve started to write samples to implement all the ACT features with jQuery (and jQuery plugins), you can read more HERE.

Here is the effect we’re looking for, a hint to the user as to the desired or required input (note this sampe doesn’t do input validation, we’ll do that in a later demo.)

To get this we’re going to use jQuery and the TinyWatermark jQuery plugin.

The effect is completely applied in our markup. There is no server side implementation.

I like this as I prefer to off load as much work as possible to the client machine.


<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
                 AutoEventWireup='true' CodeFile='Default.aspx.cs'
 Inherits='_Default' %>
<asp:Content ID='HeaderContent' runat='server'
             ContentPlaceHolderID='HeadContent'>
    <script src='Scripts/jquery-1.4.1-vsdoc.js' type='text/javascript'>
</script>
    <script src='Scripts/jquery_tinywatermark-3_1_0.js'
        type='text/javascript'>
    </script>
    <style>
        .watermark
        {
        color:#999;
        background-color: #FFD4D4;
        font-style: italic;
        }
    </style>
    <script type='text/JavaScript'>
        jQuery(function ($) {
            $('.watermarked').watermark('watermark');
        });
    </script>
</asp:Content>
<asp:Content ID='BodyContent' runat='server'
             ContentPlaceHolderID='MainContent'>
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit
        <a href='http://www.asp.net'
		   title='ASP.NET Website'>www.asp.net</a>.
    </p>
    <p>
        Please enter your email address here ......<br />
        <input type='text' class='watermarked' size='50'
                  title='Enter Email Address here...' />
    </p>
</asp:Content>

Note that in the “HeadContent” placeholder I pull in jQuery and the TinyWatermark jQuery Plugin. (I’m using the VSDOC version for the best experience in Visual Studio but you should use the MIN version in production, and consider using the Microsoft CDN

Starting on line 7 I specify a style to be used for the watermark (and names .watermark)

Any texbox that I want to be watermarked I set it’s class=watermark

Note also that the jQuery plugin will use the title attribute as the text to displain in the textbox when the watermark is active as set on line 31.

Then all we have to do is simple apply the JavaScrpt function that begins on line 16.

You can download a runnable sample [ HERE ]


ASP.NET Rounded Coreners AND DropShadow with jQuery.

I’ve started blogging examples of how to replace Microsoft AJAX and the Ajax Control Toolkit usages with jQuery based equivalents.

In this post I showed how to replace the ACT’s Rounded Corner Extender with jQuery and in this one I demonstrated how to replace the Drop Shadow control extender with jQuery.

But lots of folks want to do both at the same time like this.

For this I’m going to use yet another jQuery Plugin – Liquid Canvas.

The code below also demonstrates two different styles of applying the effect. One targets elements with a specific ID and the other targets any element that uses a particular CSS class.



<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
         AutoEventWireup='true' CodeFile='Default.aspx.cs'
		 Inherits='_Default' %>
<asp:Content ID='HeaderContent' runat='server'
             ContentPlaceHolderID='HeadContent'>
    <!--[if IE]>
    <SCRIPT type=text/javascript
    src='Styless/excanvas.js'></SCRIPT>
    <![endif]-->
    <script src='Scripts/excanvas.js' type='text/javascript'></script>
    <script src='Scripts/liquid-canvas.js' type='text/javascript'></script>
    <script src='Scripts/liquid-canvas-plugins.js' type='text/javascript'>
	</script>
    <SCRIPT type=text/javascript>
      $(window).load(function() {
          $('#Panel1').liquidCanvas(
            '[shadow fill] => roundedRect{radius:10}');
          $('.rounded').liquidCanvas(
            '[shadow fill] => roundedRect{radius:10}');
      });
    </SCRIPT>
</asp:Content>
<asp:Content ID='BodyContent' runat='server'
     ContentPlaceHolderID='MainContent'>
    <h2>Welcome to ASP.NET!</h2>
    <br /><br />
    <asp:Panel ID='Panel1' runat='server' ClientIDMode='Static'
	                                      style='width: 400px;'>
      <p>&amp;nbsp;&amp;nbsp;&amp;nbsp;Some Developer Links</p>
	  <ol>
	    <li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 1</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 2</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 3</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 4</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 5</a>
		</li>
      </ol>
    </asp:Panel>
    <br /><br />
    <asp:Panel ID='Panel2' runat='server' ClientIDMode='Static'
	           style='width: 400px;'
               class='rounded'>
      <p>&amp;nbsp;&amp;nbsp;&amp;nbsp;Some Developer Links</p>
	  <ol>
	    <li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 1</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 2</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 3</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 4</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 5</a>
		</li>
      </ol>
    </asp:Panel>
</asp:Content>

The previous posts demonstrate perfectly viable ways to achieve a specific effect, in concert these posts also demonstrate that jQuery has a broad and growing eccosystem and that there are multiple ways to accomplish any given task or effect.

I highly erncourage you to dig deeper into Liquid Canvas as it ofer FAR more functionality than presented in this post.


ASP.NET DropShadow with jQuery.

As I started in this blog post, I’m creating jQuery based samples for all of my origional Ajax and Ajax Control Toolkit guidance. (Find it here.)

In this video I demonstrated adding “DropShadow” visual effects to ASP.NET controls using the DropShadow Control Extender from the ASP.NET Ajax Control Toolkit.

As you might expect, and as you are probably getting used to hearing, “there’s a jQuery Plugin for that”.

You can grab the jQuery “Drop Shadow” plugin HERE.

One of the super powerful things about jQuery is that you can easily select (and apply attributes) via a number of criteria like CSS Class, Element Id, type, etc. For an introductory tutorial on jQuer Selectors read here, for the API documentation read here.

We can add a dropshadow to an ASP.NET container by assigning that container a specific CSS class or ClientId. (Please review ASP.NET 4′s ClientId features HERE.)

It will look like this.

and the code looks like this…..


<%@ Page Title='Home Page' Language='C#' MasterPageFile='~/Site.master'
         AutoEventWireup='true' CodeFile='Default.aspx.cs'
		 Inherits='_Default' %>
<asp:Content ID='HeaderContent' runat='server'
             ContentPlaceHolderID='HeadContent'>
    <script src='Scripts/jquery.dropshadow.js' type='text/javascript'>
	</script>
    <script type='text/javascript'>
            $(document).ready(function () {
                $('.rounded').redrawShadow();
                $('#Panel3').redrawShadow();
            });
    </script>
</asp:Content>
<asp:Content ID='BodyContent' runat='server'
     ContentPlaceHolderID='MainContent'>
    <h2>Welcome to ASP.NET!</h2>
    <br />
    <asp:Panel ID='Panel1' runat='server' ClientIDMode='Static'
               style='background-color:#acc; padding:5px; width: 400px;'>
      <p>&amp;nbsp;Some Developer Links</p>
	  <ol>
	    <li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 1</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 2</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 3</a>
		</li>
      </ol>
    </asp:Panel>
    <br />
    <asp:Panel ID='Panel2' runat='server' ClientIDMode='Static'
         style='background-color:#acc; padding:5px; width: 400px;'
		 class='rounded'>
      <p>&nbsp;Some Developer Links</p>
	  <ol>
	    <li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 1</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 2</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 3</a>
		</li>
      </ol>
    </asp:Panel>
    <br />
    <asp:Panel ID='Panel3' runat='server' ClientIDMode='Static'
         style='background-color:#acc; padding:5px; width: 400px;'>
      <p>&amp;nbsp;Some Developer Links</p>
	  <ol>
	    <li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 1</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 2</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 3</a>
		</li>
      </ol>
    </asp:Panel>
    <br />
</asp:Content>

Note the inclusion of the jQuery.dropshadow.js file in line 4.

And then the 2 calls to redrawShadow()


<script src='Scripts/jquery.dropshadow.js' type='text/javascript'>
</script>
<script type='text/javascript'>
		$(document).ready(function () {
			$('.rounded').redrawShadow();
			$('#Panel3').redrawShadow();
		});
</script>

The first call applies a Drop Shadow to any HTML Element who’s class is set to “rounded” and the second applies a Drop Shadow to any element who’s Id is set to “Panel3″.

You can download a working sample HERE.

If you have a specific usage requirement for Drop Shadows, please email me !

Stay tuned.


ASP.NET Rounded Corners with jQuery

Remember the AJAX Control Toolkit ?

I created a LOT of content on how to use it.

While the Ajax Control Toolkit (ACT) is still around, new development on it (by Microsoft) has stopped as we have adopted a more jQuery centric strategy for client UI development.

Not only does this make sense, but I’m compleatly hooked on jQuery so I though I would start demonstrating all the UI things that you could do with the ACT by migrating them to jQuery.

In this video I demonstrated rounding the edges of markup containers in your ASP.NET UI by using the ACT RoundedCorner control extender.

Rounded corners gives our UI a smooth look and there are MANY ways to do this with images, CSS, JavaScript and jQuery.

I’ll use a jQuery plugin to round the corners of an ASP.NET Panel Control.

The final product looks like this.

ASP.NET Rounded Corners with jQuery

I’ve used the jQuery RoundedCorners PlugIn which you can find HERE

It’s TOO simple.

The default ASP.NET WebForms template includes a reference to the jQuery base by default (though you can use jQuery plugins and this code in ANY ASP.NET application.

At the top of my page that will contain rounded corners I add this markup.


    <script src='Scripts/jquery.corners.min.js' type='text/javascript'>
	</script>
    <script type='text/javascript'></script>

When the page is loaded the corners() method is called to apply the rounded corners to all the elements whose class=”rounded”.


    <asp:Panel ID='jQueryBox' runat='server' ClientIDMode='Static'
	     style='background-color:#acc; padding:5px; width: 400px;'
		 class='rounded'>
      <p>Some Developer Links</p>
	  <ol>
	    <li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 1</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 2</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 3</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 4</a>
		</li>
		<li>
		<a href='http://misfitgeek.com' target='_blank'>Developer Link 5</a>
		</li>
      </ol>
    </asp:Panel>

I told you it was TOO easy.

I’ll be doing jQuery alternatives for ALL my Microsoft Ajax and Ajax control toolkit videos.

In the mean time – you can download sample code for the above Rounded Corners demo [HERE].


ASP.NET MVC App Building Videos (61)

Building the ASP.NET MVC Music Store


Part 1: Intro, Tools, and Project Structure
Part 2: Controllers
Part 3: Views and ViewModels


ASP.NET MVC 2


Displaying a Table of Database Data
Creating Model Classes with LINQ to SQL
Creating Unit Tests for ASP.NET MVC Applications
Preventing JavaScript Injection Attacks
An Introduction to URL Routing
Understanding Views, View Data, and HTML Helpers
Understanding Controllers, Controller Actions, and Action Results
Understanding Models, Views, and Controllers
Creating a Tasklist Application with ASP.NET MVC
Understanding Models, Views, and Controllers
ASP.NET MVC Controller Overview
Creating a Movie Database Application in 15 minutes with ASP.NET MVC
How Do I: Return JSON Formatted Data for an AJAX Call in an ASP.NET MVC Web Application?
What is ASP.NET MVC? 80 minute technical video for developers, building NerdDinner
Why ASP.NET MVC? 3 minute overview video for decision makers
ASP.NET MVC: How? 10 minute technical video for developers
How Do I: Work with Data in ASP.NET MVC Partial Views?
How Do I: Create a Custom HTML Helper for an MVC Application?
How Do I: Work with Model Binders in an MVC Application?
How Do I: Use HttpVerbs Attributes in an MVC Application?
MVC 2 HTML Encoding
MVC 2 Strongly Typed Helpers
MVC 2 Model Validation
MVC 2 Template Customization
ASP.NET MVC 2 – Areas
ASP.NET MVC 2 – Render Action


ASP.NET MVC Talks


Creating NerdDinner.com
America’s Next Top MVC Framework
Ninja on Fire Black Belt Tips
ASP.NET MVC 2: Ninja Black Belt Tips


ASP.NET MVC For the Rest of Us

(Building a Contact Form App)


#1: ASP.NET MVC For the Rest of Us: Part 1
#2: ASP.NET MVC For the Rest of Us: Part 2
#3: ASP.NET MVC For the Rest of Us: Part 3
#4: ASP.NET MVC For the Rest of Us: Part 4


ASP.NET MVC Storefront Starter Kit


#1: Architectural Discussion and Overview
#2: The Repository Pattern
#3: Pipes and Filters
#4: Linq To Sql Spike
#5: Globalization
#6: Finishing The Repository, and Initial UI Work
#7: Routing and UI Work
#8: Testing Controllers
#9: The Shopping Cart
#10: Shopping Cart Refactor and Authorization
#11: Hooking Up the Shopping Cart & Using Components
#12: Mocking
#13: Dependency Injection
#14: Rich Client Interaction
#15: Public Code review
#16: Membership Redo With OpenID
#17: Checkout With Jeff Atwood
#18: Creating An Experience
#19: Processing Orders With Windows Workflow
#19a: Windows Workflow Followup
#20: Logging
#21: Order Manager and Personalization
#22: Restructuring, Rerouting, and PayPal
#23: Getting Started With Domain-Driven Design
#24: Finis


ASP.NET 4 ClientId – I’ll do it myself thanks !

In the early days of ASP.NET most developers didn’t write client side code. They just used server side UI controls and any programmatic interface state changes were restricted to post-back processing.

Enter Ajax, RIA, Scriptable Services, Scriptaculous, YUI, jQuery, HTML5, etc.

Now ASP.NET developers, no matter what ASP.NET flavor you are using (YES, including WebForms) need to hold some of the party IN the browser.

To manipulate the Document Object Model (DOM) elements we need to know HOW to address them.

WebForms has a built in feature that pertains to the client identity of HTML elements.

ASP.NET used an algorithm to determine the client side naming of a server side control.

When we didn’t ever need to manipulate the DOM from client side code this was a service because it meant that no matter how our server side controls were nested or contained we would never have naming collision in the browser.

One less this to worry about right?

So if we used an ASP.NET server side textbox control in a container on our form (like a panel) here is what the resulting html textbox declaration would look like.


<input id='ctl00_ContentPlaceHolder1_TextBox1'
   name='ctl00$ContentPlaceHolder1$TextBox1'
   type='text' value='Text' />

Beginning with ASP.NET 4 we have the capability to define how we want ASP.NET to handle the relationship between ASP.NET server side controls and the resultant HTML element Ids.

Introducing the ClientId property.

Note that we are talking about the “ID” attribute which we will use to address the element from JavaScript and NOT the “Name” attribute.

“Name” is how the server will see that element when a form is posted to it. “ID” is how the browser sees the HTML element so that is how JavaScript addresses the element.
We now have three ways that we can instruct ASP.NET to handle client ids.

  • Static
  • Legacy
  • Predictable

And we can set this as the default at the Machine, Project, or Page level (and override it wherever we want.)

One might use legacy (the default) if they are not writing client side code. As you would expect, it works the same was it always has (described above.)

Here is how you set the default ClientId mode for the page to “Static”.


<!--Page Language='C#' AutoEventWireup='true'
      CodeFile='Default.aspx.cs' Inherits='_Default'
      ClientIdMode='Static'-->

I nearly always use static. I specify the ID of the HTML element and that is the one ASP.NET uses – period.

Of course, this means that I need to do my own ame management and make sure that the same name is never used for two controls that will appear in the DOM at any one time.

No problem.

There is one time though when “Predictable” mode is a big help.

Suppose you are using a data bound list that contains controls but since it’s data bound you don’t necessarily know how many items that container will ultimately render. “Predictable” IDs means we can “PREDICT” the Ids and therefore we can still program against the individual HTML elements that resides in the container.

So, why am I telling you this now ?

Well, over the past couple of years I have generated TONS of content on doing things with Microsoft Ajax and the Microsoft Ajax Control Toolkit. Since then we have really pitched our support to jQuery.

So, I’m now going to create new content to demonstrate how to do all those Ajax and Client UI techniques using jQuery and modern ASP.NET HTTP services.

Stay tuned and let me know which ones you want me to provide first !


Free ASP.NET MVC Training Online

The MVFConf sessions are now on-line and available for viewing or download !

del.icio.us Tags: ,,,,

ASP.NET MVC Fundamentals Videos & Tutoruals (39)

MVC Step by Step Tutorials


Build your First ASP.NET MVC 3 Application
Build an ASP.NET MVC Music Store


MVC Sample Saamplications

NerdDinner
ASP.NET MVC Music Store
Microsoft TownHall


ASP.NET MVC Overview


ASP.NET MVC Overview
Understanding Models, Views and Controllers
Understanding the ASP.NET MVC Execution Process
Create Movie DB App
ASP.NET MVC 2 Basics
Create a MVC 3 Application with Razor & Unobtrusive JavaScript


ASP.NET MVC Fundamentals Videos


Creating a Movie Database Application
Preventing JavaScript Injection Attacks
Creating Unit Tests
Creating Custom HTML Helpers
Return JSON Formatted Data for an AJAX Call
ASP.NET MVC Controller Overview
Understanding Models, Views, and Controllers
Understanding Views, View Data, & HTML Helpers
An Introduction to URL Routing


ASP.NET MVC For the Rest of Us Videos


ASP.NET MVC For the Rest of Us: Part 1
ASP.NET MVC For the Rest of Us: Part 2
ASP.NET MVC For the Rest of Us: Part 3
ASP.NET MVC For the Rest of Us: Part 4


ASP.NET MVC Routing


ASP.NET Routing Overview
Creating Custom Routes
Creating a Route Constraint
Creating a Custom Route Contstraint


ASP.NET MVC Controlers


ASP.NET MVC Controller Overview
Creating a Controller
Creating an Action


ASP.NET MVC Views


MVC Views Overview
Creating Custom HTML Helpers
Displaying a Table of DB Data
Using the Tagbuilder Class


ASP.NET MVC Testing


Creating Unit Tests


ASP.NET MVC Navigation


Providing Website Navigation with Sitemaps


ASP.NET MVC Performance


Improving Performance with Output Caching
Adding Dynamic Content to a Cached Page


Contoso Karate Feature Demo Available for Download

In recent weeks I’ve been publishing “Chapter Videos” on building Web Sites with Microsoft WebMatrix ( Watch Them HERE )

There will be 21 in total for this introductory series (they are all done and the last of them are in the production pipeline now.)

For those who are following along you can now download the code base I’ve been building in the videos. This is not a “sample application” per se, but rather a collection of feature demos.

A real sample application is in the works.

[ Download the Contoso Karate Feature Demo HERE ]

List of Microsoft Web Development Walkthroughs

I can’t take credit for building these lists, I think JD Meier assembled them before he moved to the Enterprise Strategy group. Since I’m building a list of existing Web Learning Resources I thought I would save them here for my referece and yours.


Introductory


Topic Description
Introduction: Planning an ASP.NET Web Site Provides an overview of the factors that you should consider when you design a Web site. The topic provides links to topics that provide additional information about individual subjects.
Walkthrough: Creating a New ASP.NET Web Site Provides an introduction to the Web development features of Visual Web Developer and guides you through creating a simple ASP.NET page.
Walkthrough: Code Editing in Web Pages in Visual Web Developer Illustrates various features of the code editor. Some of the features of the code editor depend on what language you are coding in. Therefore, in this walkthrough you create two pages, one that uses Visual Basic and another that uses C#.
Walkthrough: Creating a Basic Web Page with Code Separation in Visual Web Developer Provides an introduction to creating Web pages in Visual Web Developer. It guides you through creating a simple page, illustrating the basic techniques of creating a new page, adding controls, and writing code.
Walkthrough: Creating and Modifying a CSS File Introduces the features of Visual Web Developer for working with cascading style sheets (CSS). It guides you through creating a three-column page layout, illustrating the basic techniques of creating a new Web page and a new style sheet.
Walkthrough: Validating User Input in a Web Forms Page Illustrates how to use ASP.NET validation controls to check user input in a Web page.
Walkthrough: Basic Data Access in Web Pages Shows you how to create a simple data-bound page by using controls that are designed specifically for data access.
Walkthrough: Displaying, Paging, and Sorting Data Using the ListView Web Server Control Illustrates how to work with the ListView control, which enables you to display data in a format that you define by using templates. By working with templates, you can have complete control over the layout and appearance of the data in the control.
Walkthrough: Creating Master/Detail Web Pages in Visual Studio Shows you various ways to work with data in multiple controls and from multiple tables, which includes those that have a master/detail relationship.
Walkthrough: Retrieving, Updating, Inserting, and Deleting Data with the LinqDataSource and DetailsView Controls Shows you how to create a simple database table and a Web page that uses the LinqDataSource control. The Web page enables users to retrieve, update, insert, and delete data from the database table.
Walkthrough: Adding Site Navigation to a Web Site Illustrates how to create site navigation by using various navigation controls, such as the Menu control, the TreeView control, and the SiteMapPath control, which adds a navigation path to Web pages.
Walkthrough: Displaying a Menu on Web Pages Shows you how to add a menu control to a page and use it as a navigation tool.
Walkthrough: Creating a Web Site with Membership and User Login Shows you how to use ASP.NET controls and ASP.NET membership services to create pages that let users log in and work with member-only pages.
Walkthrough: Creating an AJAX-enabled Web Site Shows you how to create a basic ASP.NET Web site that has a Web page that illustrates ASP.NET AJAX features.
Walkthrough: Creating and Using ASP.NET Master Pages in Visual Web Developer Illustrates how to create a master page and several content pages. Master pages let you to create a page layout (a template page). You can then create separate pages that contain content that is merged with the master page at run time.
Walkthrough: Customizing a Web Site Using Themes in Visual Studio Shows how to use themes to apply a consistent look to pages and controls in a Web site.
Walkthrough: Debugging Web Pages in Visual Web Developer Shows you how to use the debugger. You create a Web page that contains a simple calculator that includes a deliberate error, and then use the debugger to examine the page as it is running.
Walkthrough: Copying a Web Site Using the Copy Web Site Tool Shows you how to use the Copy Web Site tool to copy files between your current Web site and another Web site.
Walkthrough: Publishing a Web Site Shows you how to use the Publish Web Site utility to compile a Web site, and then copy the output to an active Web site.

The Publish Web Site utility is not available in Visual Web Developer 2008 Express Edition.

Advanced


Walkthrough Description
Walkthrough: Modifying Data Using the ListView Web Server Control Shows you how to display and update data in the ListView control. This walkthrough uses a SqlDataSource control to retrieve results from the data source and to manage updates. The SqlDataSource control acts as the data source for the ListView control.
Walkthrough: Displaying a Drop-Down List While Editing in the GridView Web Server Control Shows you how to use the ASP.NET GridView control&#39;s advanced functionality to add a drop-down list to the editing display.
Walkthrough: Creating User-Selectable Themes Illustrates how to create an ASP.NET page that lets users select a theme for the page. Although this example uses a single control skin and a basic cascading style sheet (CSS) file, the principles shown apply to more complex themes that include graphics, different layout schemes in the CSS file, and more complex server control skins.
Walkthrough: Creating the Data Access and Business Logic Layers in ASP.NET Shows a simple example of best practices for creating a Web site that accesses a database by isolating the data-access and business-logic layers.
Walkthrough: Creating and Using an ASP.NET Web Service in Visual Web Developer Illustrates how to create and use a Web service.
Walkthrough: Creating an AJAX-Enabled Data Application Illustrates how to create a database application that includes AJAX features to refresh data on the page by using an asynchronous postback.
Walkthrough: Using Nested Master Pages in ASP.NET Shows you how to nest master pages so that the parent master page can provide a consistent layout throughout a Web site, and the child master page can be used as a template for consistent layout within the parent master page.
Walkthrough: Maintaining Web Site User Information with Profile Properties Shows you how to add profile properties to your application and how to use the profile properties to create a personalized experience for visitors to the Web site.
Walkthrough: Using ASP.NET Application Services Shows you how to assign users to roles and how to create rules (permissions) that selectively grant or deny access to pages for different roles. It also shows how to programmatically determine whether a user is in a particular role and which roles the current user is in.
Walkthrough: Managing Web Site Users with Roles Illustrates how to configure an ASP.NET Web site to expose application services for authentication, roles, and profile properties.
Walkthrough: Creating Reusable Elements with ASP.NET User Controls Shows you how to create an ASP.NET user control that acts as a picker control. The picker control has two lists, with a set of choices in one list (the source). Users can select items in the source list and add the items to the target list.
Walkthrough: Using Shared Code in Web Sites in Visual Web Developer Shows you how to create a simple class and then use it in an ASP.NET Web page where Visual Web Developer references the component automatically.
Walkthrough: Using Resources for Localization with ASP.NET Shows you how to create localization resource files and reference them in Web pages by using declarative expressions.
Walkthrough: Using Output Caching to Enhance Web Site Performance Shows you how to use output caching, which uses a pre-processed copy of a page instead of processing the page again for each request.
Walkthrough: Creating an Accessible Web Application Illustrates how to create accessible Web pages that enable you to reach as many customers as possible, such as people with disabilities and users who have slow connections or text-only browsers.
Walkthrough: Creating a Synchronous HTTP Handler Illustrates how to create an HTTP handler, which lets you create custom dynamic output other than Web pages, such as RSS feeds.
Walkthrough: Creating and Registering a Custom HTTP Module Illustrates the basic functionality of a custom HTTP module. An HTTP module is called on every request, and lets you customize how the request or response is processed.
Walkthrough: Developing and Using a Custom Server Control Shows you how to create and compile a custom ASP.NET server control and use it in a page.

Location of the machine.config file

I get this email a lot from beginners……..

Where is the machine.config file ?

As we’ve simplified the we.config file some configuration elements have been moved lower in the chain to the machine.config file.

The machine.config file is located in

[Your System Drive]:\<windows>\Microsoft.NET\Framework\<version>\config\machine.config

On my laptop the real path is :

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config

For more information on the ASP.NET configuration hierarchy [ read HERE ]

Microsoft WebMatrix is NOW LIVE !

I’m super excited that Microsoft WebMatrix is now RTW !

Check out Microsoft WebMatrix [ HERE ]

Read “Web Development 101 With WebMatrix

Stay tuned as I’m working on a collection of videos and tutorials !!!

Orchard 1.0 – We’re ready for production !

OrchardLogoCodeplex

If you’re like me you’ve been waiting with anticipation for this Orchard 1.0  !

Well, we’re LIVE.

The primary differences between 0.8 and 1.0 is bug fixes but the milestone is that we’re production ready so we can starting building sites, modules, and themes with confidence.

Get the RTW version [ HERE ]

… and if you build a Module of Theme, make sure you let me know so I can blog about it !!

Feature Sample for Microsoft WebMatrix with Razor – Beta 3

WeMatrixSampleSS

Last fall I started giving resentations on Microsoft’s cool new Web Development Stack – WebMatrix.

I put together a collection of samples to demonstrate features and common tasks. It’s not really a sample application, per se, but really just a bunch of code/features examples in a single bundle.

I’ve just updated then to work with the latest Beta 3 with is VERY close to RTM.

I hope you will download WebMatrix and the Samples a check them out !

[ Get Microsoft WebMatrix HERE ]

[ Get the code for the samples HERE ]

Podcast #3 – ASP.NET Scott Hunter

In this episode,Joe catches up with the Scott Hunter, Sr. PM Lead of the ASP.NET Team. Listen and hear about what the team is working on, how they plan and decide on new products and features, and more.

RESOURCES  

 Subscribe


   MP3

   WMA

   M4A

   Zune

   iPod

 Download


   MP3

   WMA

   M4A

   Zune

   iPod

Dynamic Page Menus in WebMatrix Templates with CSS and jQuery.

A basic practice in software development of all types is to use mechanisms that allow us to write and maintain code in a single place no matter how many difference places that code is used throughout our entire application.

When we’re building web sites, and more specifically web pages, the reuse of UI code can be especially challenging as the nature of web applications are stateless and in most models there is a 1-to-1 relationship between endpoints and “files”.

In ASP.NET WebForms we have master pages.

In Microsoft WebMatrix we have Layout Templates.

One of the advantages of the general move towards “standards based” web development is that HTML, CSS, and JavaScript can generally be used across different web development platforms and the technique described below can be used no matter which ASP.NET Development model you choose. (WebForms, ASP.NET MVC, WebMatrix)

I’ll use WebMatrix for the example.

Given a WebMatrix site created using the default “Starter” template the following Home Page and About Page can be displayed when the project is run.

Note that only the text inside the white area of the pages is different in the Default.cshtml and About.cshtml pages.

Read the rest of this entry »

Building a Sample WebMatrix Application

Microsoft-WebMatrix-1278498927

Last year I built a sample WebForms application modeled after the original iBuySpy ecommerce application called TailSpin Spyworks.

I thought it would be interesting to build something “real” using Microsoft WebMatrix.

The web site I’ve settled on is a Kids Sports Team Portal. Here are some of the features I’m planning on.

  • Season Game Schedule with front page reminder.
  • Game Results archive with front page “most recent” game results.
  • Practice Schedule.
  • Push updates to parents email list.
  • Parent’s notification (option to advice coaches that a child will be absent.)
  • Restricted access photo gallery with parent’s contributions.
  • Restricted access video gallery with parent’s contribution.
  • Some social networking integration.

I’ll be starting with an open source template.

As I’m starting to plan and build, WHAT FEATURES WOULD YOU RECOMMEND !

Technorati Tags: ,WebMatrics,

Tailspin Spyworks Ecommerce Application and Tutorial Updated on CodePlex !

Just a note to let folks know that I’ve updated both the code and the tutorial for the tailspin Spyworks sample app at http://tailspinspyworks.codeplex.com/.

It includes bug fixes, additional step details in the tutorial as well as complete database schema information.

Enjoy and feel free to send comments and suggestions.

35 Developer Learning Pain Points

A few weeks ago I asked developers to tell me what heir top “learning pain points” were.

I got GREAT input that I intend to use to drive much of the guidance that I will build in 2011.

Below is a list of the top results.

Please feel free to add or comment.

————————————————————

1.) Choosing between Web Forms, MVC, WebMatrix or something else entirely.

2.) Choose Windows Forms, WPF, Silverlight or something else for desktop development. 

3.) Choosing a data access method (ADO.NET, LINQ to Objects, LINQ to SQL, Entity Framework, NHibernate, embedded SQL) and how to use that choice in application architecture. What are the good practices, should I use binding? Etc.?

4.) Choosing between ASMX or WCF (When SHOULD I use WCF)

5.) Determining the right practices and patterns for asp.net development.

6.) Finding examples of non-trivial applications with great documentation and tutorials.

7.) How to build, consume, and manage Reusable Code (Libraries, Frameworks, Controls).

8.) Microsoft guidance focuses on HOW, but not when and why. Proved “Best Practices”.

9.) Moving from WebForms Controls to JavaScript (jQuery) (How, Why, and When to choose which.)

10.) Show me how to do Grids and all other WeForms control functions in jQuery.

11.) Should I choose jQuery or ASP.NET AJAX (and how do I use jQuery to do all the things that I used to do in ASP.NET AJAX and the Ajax Control Toolkit.

12.) Deciding whether to use Silverlight in an ASP.Net app.

13.) Complete guidance on REST with samples of working will all major REST APIs (Twitter, Facebook, etc.)

14.) How to do OO Design & Coding with .NET (I never really had to learn)

15.) Changing our development practices to follow more of a TDD model.

16.) Source code management tool options. VSTS and cheaper solutions (CVN)

17.) How do implement a true and Abstract DAL 

18.) How to build a good BLL with validation (required fields, etc…) in front of an Entity Framework DAL.

19.) I need a complete strategy for SEO. Microsoft has some tools, but no complete story!

20.) How do I design and build for high performance and how to I troubleshoot performance problems.

21.) Understanding stateless application development. WebForms handled “state” for me. MVC and WebMatrix don’t.

22.) Building a business case for management to migrate a Classic ASP (VBScript) (90% of app) to ASP.Net MVC instead of ASP.Net WebForms (10% of app).

23.) Building a business case for migrating Classic ASP to ASP.Net (Choosing MVC or WebForms)

24.) How to understand and get started with ASP.NET MVC. (I’ve been an ASP.NET developer for years and have looked at the MVC samples but it’s too complex and requires advanced OO skills.)

25.) Application deployment is a mess. Which versions of .NET, IIS, SQL ? How to automate deployment? What works side-by-side? How to manage SQL schema updates.

26.) Should I use Stored Procedures or not now that we have LINQ and EF? How do I manage versioning of Stored Procs if I use them.

27.) I need to understand and use the ASP.Net security model, providers, etc.

28.) I need to understand How the .net framework versions work (and don’t work) together.

29.) I need detailed guidance about how to make my (web) application multi lingual. Should I use resource files, a SQL Database?

30.) ASP.NET Membership and Profile management is far too weak. Show my how to take both to the next level and highly customize them.

31.) My team has major confusion over dataset binding in controls versus lists / listview, use of business objects and all the choices. Which controls are best to use for what user interface types and what is the best way to use data with those controls.

32.) Help me learn how to deal with service binding and endpoint configuration headaches in my ASP.NET application; especially when developing on localhost (http) and deploying to a secure environment (https)… resulting in "works on my machine" syndrome.

33.) I need to understand the UpdatePanel (AJAX) and how it affects the page life cycle, security, and interaction between multiple UpdatePanels on same Page. Should I even be using the UpdatePanel? Is it going away? What is Microsoft’s plan for their AJAX stuff which seems to be going away and being replaced by jQuery.

34.) Now that we’re doing more client side coding I need to really understand ViewState. It seems like a black box.

35.) How should I keeping up with new releases? How do I decide when to move to new versions.

 

Technorati Tags: ,,Learvning

ASP.NET & ADO.NET Code Samples Collections

J.D. Meier (my team mate here in Developer Guidance) recently put together these lists of samples.

I’m sharing them here so I can easily refer to them. While your looking, go over and subscribe to J.D.’s blog (where he also published these). He does awesome stuff.

 

ASP.NET Code Samples Collection

Category Items
Sample Applications

ASP.NET MVC

AJAX / jQuery All-in-One Code Framework

Code Gallery

Microsoft Support

Authentication Code Gallery

Customer Support

Authorization Code Gallery

CSS 2
Data Access All-in-One Code Framework

Code Gallery

Exception Management Code Gallery

Microsoft Support

JavaScript / JSON Code Gallery

Logging and Instrumentation patterns & practices

MVC Code Gallery

Navigation Codeplex

Request Processing ASP.NET Developer Center (www.ASP.NET)

State / Session Management Code Gallery

Validation Code Gallery

Visual Studio and ASP.NET Development Code Gallery

Microsoft Support


Category Items
Data Binding MSDN Library

Data Models Code Gallery

Microsoft Support

DataReader MSDN Library

DataSet MSDN Library

DataTable MSDN Library

Entity Framework All-in-One Code Framework

Code Gallery

General All-in-One Code Framework

MSDN Library

LINQ to DataSet MSDN Library

LINQ to Entities MSDN Library

LINQ to Objects All-in-One Code Framework

LINQ to SQL All-in-One Code Framework

Code Gallery

Code Gallery

N-Tier Code Gallery

O/RM Mapping Code Gallery

OData Code Gallery

POCO
Silverlight Code Gallery

SQL Server MSDN Library

Streaming Code Gallery

WCF Data Services All-in-One Code Framework

Code Gallery

A List of Resources to help jumpstart your ASP.NET WebMatrix Development.

WebMatrix Stack

Building ASP.NET Web Pages using the Razor Syntax (PDF Book) :

ASP.NET Web Pages With Razor Syntax – Book -  Beta 2 – PDF

Microsoft on line resources :

WebMatrix on the ASP.NET Community Site

WebMatrix on the IIS.NET Community Site

Full project downloads on the Microsoft Download Center

Using WebMatrix Beta 2

Create an ASP.NET Website from Scratch

How to Choose a Template and Create a New Website Using WebMatrix Beta

Add and Edit ASP.NET Web Pages

Download and Install an ASP.NET Application

Analyze Requests to your Website

Make your Website SEO friendly

Publish a Website

Migrate a Database to SQL Server

Download and Install a PHP Application

Create a Website from a Gallery Application (WordPress)

WebMatrix Beta 2 Release Readme

ASP.NET Web Pages with Razor Syntax Beta 2 (individual tutorials from the book above).

Get the Code Samples Download!

Get the eBook Download!

Getting Started with WebMatrix Beta and ASP.NET Web Pages

Introduction to ASP.NET Web Programming Using the Razor Syntax

Creating a Consistent Look

Working with Forms

Working with Data

Displaying Data in a Grid

Displaying Data in a Chart

Working with Files

Working with Images

Working with Video

Adding Email to Your Web Site

Adding Search to Your Web Site

Adding Social Networking to Your Web Site

Analyzing Traffic

Caching to Improve the Performance of Your Website

Adding Security and Membership

Introduction to Debugging

Customizing Site-Wide Behavior

ASP.NET API Quick Reference

ASP.NET Web Pages Visual Basic

Using IIS Developer Express

IIS Developer Express Overview

Use the Windows System Tray to Manage Websites and Applications

Use the Command Line to Run a WebMatrix Site or Application

Thanks to Wade Pickett for compiling this list !

Taxonomy_v1

In order to map Developer Guidance offerings across the entire breadth of Microsoft’s web development technologies I’m starting to document a broad taxonomy.

I put together this collection of HIGH LEVEL “buckets”.

[ You can see the diagram full size by clicking HERE ]

So friends, two questions.

1.) Did I miss any HIGH level bucket ?

2.) If you’re interested, take one of these buckets enumerate the next nesting level for that topic.

This is a work in process, I’ll update http://misfitgeek.com/taxonomy/ as I expand the taxonomy.

THANKS !

Choosing between ASP.NET–WebForms, MVC, WebMatrix – Choice is a GOOD thing.

Yesterday Microsoft announced new (beta) releases of  a number of forthcoming web development technologies. [ Read HERE ]

A member of one of the mailing lists I’m on was very upset! He complained that TWO choices were two many (WebForms and MVC) and adding a THIRD (WebMatrix) was simply ridiculous.  I know he was serious because he said “seriously” many times.

ScottGu posted an interesting opinion [ About Technical Debates (and ASP.NET Web Forms and ASP.NET MVC debates in particular)  ] on his blog some time ago.

Now that I’m MSJoe and not the MisfitGeek, I’m trying to be more political correct (as demanded by management : ) ), and I don’t mean to call out that specific individual, but the email thread got me to thinking.

If you read the developer blogosphere, there are many thousands of developers out there that are sure they could do a better job guiding Microsoft Developer Platform Strategy than our current leadership, they just choose not to come be part of the solution, but in this instance someone was saying that “choice options” are a bad thing.

Now, no one was saying that THE choice (WebMatrix) was bad, only that having three different options to choose from was bad.

I think people complain about having choices comes from one of three things.

1.) I don’t want to have to MAKE choices, either because I don’t want to (or have the time) to learn about the choices so that I can make the right choice for my needs.

2.) Confidence issues. I don’t want to have to make a choice because I might not make the right one (or be able to defend it.)  If there is only ONE choice then I can’t get blamed for it

3.) I already MADE my choice so no other choices should be needed by anyone, any where ever !

BAD choices can be bad, but have several good choices is just…. well, good.

So, I’ll talk about the three choices (and really there are more than three.)

1.)  ASP.NET WebForms

It’s become fashionable in some circles to say “WebForms sucks”.

Look back a decade to when ASP.NET WebForms first hit the street and reflect on how WebForms was pure genius back then.

People were building “Client / Server” applications with Visual Basic, Borland Delphi, PowerBuilder, etc. and suddenly everyone needed to move business applications to the World Wide Web. ASP.NET WebForms gave developers a way to do that using the exact development paradigm that they had already been using for years in the Client Server world without having to learn much f anything about how the Internet or the World Wide Web actually worked.

It was a brilliant solution to the problem of the day – get developers productively building applications for the web with as little time lag and learning curve as possible !

ASP.NWET WebForms FTW !!!!

Only many years later has the technical abstraction provided by ASP.NET WebForms become a hindrance. (And really, only a hindrance to some developers.)

So if you are a web developer building applications with ASP.NET WebForms should you move to something else ?

Not necessarily.

There are LOTS of GREAT web applications built with ASP.NET WebForms. If it works for you – keep doing it.

Also, there are many different STYLES of development possible with ASP.NET WebForms.

If certain parts of the WebForms layer get in the way, you can probably turn it off, or not use it.

Don’t like ViewState, turn it off (at whatever level of granularity you like).

Don’t like the WebForms Controls, don’t use them (replace them with jQuery UI ! )

1950-PanHead

This 1950 Harley Davidson Pan Head has modern paint and an after market seat but is still an awesome choice !

I still write new applications in ASP.NET WebForms.

2.) ASP.NET MVC

Proponents say MVC is the “Modern” way.

MVC is a “Pattern” that has been in use for more than THIRTY years. ASP.NET MVC is an implementation of that pattern for building .NET Web Applications.

There are good reasons to choose ASP.NET MVC for your new Web Application Development.

  1. Pattern supported separation of concerns. (Though undesirable development practices can break this model.)
  2. Embrace (rather than abstract) the underlying nature of the World Wide Web.
  3. Strong facilities for Unit Testing.
  4. Well suited to “Agile” development practices.

Certainly one can do all those things with ASP.NET WebForms, but ASP.NET MVC was designed and built with these things in mind.

There is a rather steep learning curve to start working with ASP.NET MVC. The implementation relies heavily on development by “convention” which means you need to spend time figuring out where certain things HAVE TO go or what the names of CERTAIN things MUST be.

And, there are choices to be made such as with View Engine to use (Forms, Razor, etc.)

When it comes to UI you’re sort of on your own (which some of us really like) though there is tooling support built in for jQuery coding.

The most important reason for one to choose ASP.NET MVC is simple.

Because it most facilitates they way you WANT to build web software !

If I were building a new application that was going to be built and maintained by a single company I would probably  choose ASP.NET MVC.

3.) ASP.NET WebMatrix

Ahhh, now for the “New Kid on the Block”. 

This is the one the uber-geeks say we don’t need.

I say they’re WRONG.

ASP.NET WebMatrix is not an APPLICATION Centric development methodology (like ASP.NET MVC), it is a PAGE CENTRIC development model.

The first important thing to note in this regard is that MANY Web Developers simply PREFER this model for developing Web Applications.

MANY web applications are built this way without the mandatory implication of a specific pattern, without Unit Testing, without Agile methodologies, etc.

In fact, most of the MOST popular web applications have been built this way.

Classic ASP developers work this way. So do PHP developers.

WebMatrix is perfect for Web SITES – and much of what we use on the web are more “sites” than applications”.

The web “page” model also has a special place in community driven Open Source development.

Projects like WordPress have grown HUGELY successful due to wide spread community involvement. The page centric development model really resonates well because the learning curve for contribution is low enough to offer rapid satisfaction. One doesn’t need to “get” the architecture, etc to start building and sharing things of interest to them.

And, like all the technologies I’ve been talking about here you are free to use the JavaScript strategy of your choice, AJAX, Silverlight, Flash, etc. – whatever you desire. 

So, which to choose ?

Yea, I know we tend to like it when there is a clear winner, or at least when someone declares a clear winner, even if you disagree.

The problem is that there are “hard” criteria but in the end, preference wins.

Some people drive a sports car, others drive trucks. (I bought an SUV with a big v8 engine so I get utility and whiplash whan I stomp on the pedal.)

I can’t TELL YOU when YOU should choose, but I can tell you how I choose.

 

I choose WebForms When ……

I don’t have the issues with WebForms that some folks seem to have developed. I don’t find it that difficult to get under the covers and I don’t mind writing custom controls if I need to. Still, more and more I find that WebForms makes sense to me when I’m building “behind the firewall” applications.

  • An app who’s UI can mostly be limited to the ASP.NET WebForms controls.
  • An application that will be GRID Centric.
  • An app that is mostly Data and the Screens that show / edit them. (Little “business logic” need be added.
  • Rapid Prototypes or Use & retire applications.

 

I choose ASP.NET MVC When …..

  • The app wants to be a “Web 2.0” type thing.
  • The UI will need to be complex and or very interactive.
  • The application will have a great deal of business logic and / or is mission critical.
  • The app needs to have an extended functional lifespan and will experience evolutionary iterations.

I choose WebMatrix when …..

  • The “app” is “Site Centric”.
  • UI is king but data and business logic are minimal.
  • I want the application to be Open Source AND I want it to take on a life of its own.

Still, I continue to work with all three.

ASP.NET Developers–What are your FIVE biggest learning pain points ?

Ok ASP.NET Dudes and Dudettes…..

From a learning perspective, can you share with me your 5 current “Learning Pain Points” ?

Example:

1.) Choosing between ASP.NET MVC, Web Forms, and WebMatrix

2.) Integrating jQuery into my ASP.NET Application ?

3.) Building REUSABLE code libraries ?

4.) Learning how to implement REST based Features in ASP.NET

5.) Deciding whether to use Silverlight in my ASP.NET Application.

I just made those up but you get the idea.

You can post YOUR 5 here or send them to my at this link – http://misfitgeek.com/blog/contact/

THANKS for your input !

HELP WANTED–A few reviewers needed for Tailspin Spyworks Tutorial Update.

I’ve been working on an update to the Tailspin Spyworks Tutorial (http://www.asp.net/web-forms/samples/tailspin-spyworks)

If you have time and interest to load and run the code in Visual Studio and / or walk through the tutorial and build the application and provideo me with feedback about what is wrong or missing….

PLEASE contact me and let me know !!!  I’ll send you the updates !

THANKS

2 New How-Do-I Videos Published

These 2 videos are now live:

· Simple Web Service Authentication

· Creating Inactive Users

Tailspin Spyworks videos 13 and 14 are now live

Tailspin Spyworks – Creating and Using the Popular Products Control

Tailspin Spyworks – Implementing and Using the Also Purchased Control

Exposing Java Implemented Logic – JSP or ASP.NET ?

A developer emailed me this weekend because he had just taken a position in a large software development organization and his first task was to present a discussion top management as to the relative strengths and weakness of developing new web based functionality in ASP.NET versus JSP.

During the .COM boom I did a lot of Java development. While I liked the language very much, there was much I disliked about the experience (at least as it compared with my expectations).

The middleware back in that day was cumbersome and the write once / run anywhere mantra (which I don’t think was ever entirely true) was really exacerbated by the middleware implementations. (Though JBoss happened later and I think JBoss is a super implementation.)

I never grew to like JSP. Working with JSP had little in common with the experience of working with Servlets or EJBs – where I spent my time.

The evolutionary pace of JSP seems to have really slowed and now that Sun has been acquired by Oracle who knows what will happen to Sun’s development technology. (The futures disclaimers that appear across the Sun/Java sites might indicate a cause for concern.)

ASP.NET, PHP, Python, and Ruby / RoR are all modern, evolving web development technologies.

So WHY would a company choose to do new development in JSP?

In a word – immutable Servlets.

If I had a great deal on intellectual property in Java Servlets (more than I could reasonably port out of Java in my required time frame) and I COULD NOT modify the Servlets – then I’d probably choose JSP. JSP is hard wired to talk to Java Servlets.

Of course, if I COULD modify the Servlets, my first architectural preference would be to expose the Servlet functionality through XML Web-Services, or if performance issues demanded it, via Sockets directly.

Java, .NET and PHP all have Sockets APIs.

One advantage that .NET has over PHP for this purpose is that .NET supports a binary component model so one could start building Web based UI to expose the Servlet logic and as new development progressed the Servlet architecture could be slowly migrated to .NET objects.

All in all, the question got me wondering how many folks are dealing with updating and extending existing Java infrastructure.

How are you doing it? What technologies are you choosing ?

Buttons with Mouse-Over Behaviors – Redux

I recently posted some CSS and HTML snippets for a buttons collection I was using for a Menu style UI Scott Koon from www.LazyCoder.com posted a comment with a better way (thanks Scott). This way I don’t have to set the CSS Class for each button. Just contain them in a div. Here is the CSS

CSS
  1. div input:hover
  2. {
  3. background-color: #BFCBD6;
  4. }
  5.  
  6. div input
  7. {
  8. vertical-align: middle;
  9. text-align:center;
  10. width: 150px;
  11. height: 40px;
  12. border: 1;
  13. border-color: Silver;
  14. background-color: #465C71;
  15. color: White;
  16. }

And here is the markup.

ASP.NET Markup
  1. <%@ Page Title="Home Page" Language="C#"
  2. MasterPageFile="~/Site.master"
  3. AutoEventWireup="true"
  4. CodeBehind="Default.aspx.cs"
  5. Inherits="Button_CSSSelector._Default" %>
  6. <asp:Content ID="HeaderContent" runat="server"
  7. ContentPlaceHolderID="HeadContent">
  8. </asp:Content>
  9. <asp:Content ID="BodyContent" runat="server"
  10. ContentPlaceHolderID="MainContent">
  11. <div style="text-align: center;">
  12. <h2>Administration</h2>
  13. </div>
  14. <hr /><br />
  15. <div style="text-align: center;">
  16. <asp:Button ID="btnAdminUsers" runat="server"
  17. Text="List Users"
  18. PostBackUrl="" />
  19. &nbsp;&nbsp;
  20. <asp:Button ID="btnAdminActivate" runat="server"
  21. Text="Inactive Users"
  22. PostBackUrl="" />
  23. &nbsp;&nbsp;
  24. <asp:Button ID="btnAdminEvents" runat="server"
  25. Text="Locked Out Users"
  26. PostBackUrl="" />
  27. &nbsp;&nbsp;
  28. <br /><br />
  29. <asp:Button ID="btnAdminRoles" runat="server"
  30. Text="Roles"
  31. PostBackUrl="" />
  32. &nbsp;&nbsp;
  33. <asp:Button ID="btnAdminAccess" runat="server"
  34. Text="Access Security"
  35. PostBackUrl="" />
  36. &nbsp;&nbsp;
  37. <asp:Button ID="btnAdminSettings" runat="server"
  38. Text="Application Settings"
  39. PostBackUrl="" />
  40. &nbsp;&nbsp;
  41. <asp:Button ID="btnAdminReporting" runat="server"
  42. Text="Reporting"
  43. PostBackUrl="" />
  44. &nbsp;&nbsp;
  45. <asp:Button ID="btnAdminMisc" runat="server"
  46. Text="Misc"
  47. PostBackUrl="" />
  48. &nbsp;&nbsp;
  49. </div>
  50. </asp:Content>

ASP.NET Membership Training – 3 new Videos

Hi folks. Here are three more videos in my collection on Security concepts and working with ASP.NET Membership

· Adding Users to Your Membership System

· Logging Users Into Your Membership System

· Implement the Registration Verification Pattern

You can find them all at the Web Forms Security page: http://www.asp.net/web-forms/security

image

Have you checked out the Tailspin Spyworks sample application ?

[ Start HERE ]

New Video Series – Learning Microsoft WebMatrix.

Have you heard about ASP.NET WebMatrix ?

There is a new dev tool and installer, a new syntax for developing ASP.NET Web Pages, IIS, SQL Compact.

Here are links to the first two videos in a new series for learning WebMatrix Development.

  1. Getting Started with WebMatrix Beta and ASP.NET Web Pages
  2. Introduction to ASP.NET Web Programming Using the Razor Syntax

 

wm-image_0b134c68-94f5-4abd-89f7-702e3fc0b64c

These videos will linked to a multi-chapter written tutorial series you can find at the link below.

[ Written tutorial series. ]

More coming son !

New Videos and Tutorials for this Week.

I have this GREAT Site Manager that manages the release mechanics of my content on the ASP.NET web site (THNAKS TERRI !)

Here is a list of content that went live this week:

Videos

· ASP.NET MVC For the Rest of Us: Part 4 (Monday, July 19)

· Tailspin Spyworks – Adding User Product Reviews (Wednesday, July 21)

· Tailspin Spyworks – Displaying User Reviews (Wednesday, July 21)

Tutorials (Tailspin Spyworks) – Wednesday, July 21

· Part 1: File-> New Project

· Part 2: Data Access Layer

· Part 3: Layout and Category Menu

· Part 4: Listing Products

· Part 5: Business Logic

· Part 6: ASP.NET Membership

· Part 7: Adding Features

· Part 8: Final Pages, Exception Handling, and Conclusion

There is also a shiny new landing page for Tailspin Spyworks: http://www.asp.net/web-forms/samples/tailspin-spyworks

And, there is a videos RSS feed: http://www.asp.net/rss/videos, and a tutorials RSS feed: http://www.asp.net/rss/tutorials

Have fun !

Technorati Tags: ,WebForms,,,,,

I’m building a drop-in page library for administering ASP.NET Application Services (Membership, Roles, etc) on a public web site.

On the default.aspx page in my Admin folder I wanted a

I didn’t want a top menu, a fancy tree view, etc. using ASP.NET buttons. I’m using buttons because the click event can either be a navigation or an event handler in code behind.

Here is the look

image

In my /Admin folder I “cloned” the default Master.page (now /Admin/Admin.Master).

Next – I created an Admin.css file in the/Admin directory.

Code Snippet
  1. .adminButton
  2. {
  3.     vertical-align: middle;
  4.     text-align:center;
  5.     width: 150px;
  6.     height: 40px;
  7.     border: 1;
  8.     border-color: Silver;
  9.     background-color: #465C71;
  10.     color: White;
  11. }
  12.  
  13. .adminButton:hover
  14. {
  15.     background-color: #BFCBD6;
  16. }

 

In the Admin.Master page I added the Admin.css reference to the <head> element.

Code Snippet
  1. <head id=”Head1″ runat=”server”>
  2.     <title></title>
  3.     <link href=”~/Styles/Site.css” rel=”stylesheet” type=”text/css” />
  4.     <link href=”Admin.css” rel=”stylesheet” type=”text/css” />
  5.     <asp:ContentPlaceHolder ID=”HeadContent” runat=”server”>
  6.     </asp:ContentPlaceHolder>
  7. </head>

Then I put the ASP.NET Buttons on my default page like this.

Code Snippet
  1. <asp:Content ID=”Content2″ ContentPlaceHolderID=”MainContent” runat=”server”>
  2.     <div style=”text-align: center;”><h2>Administration</h2></div><hr /><br />
  3.     <div style=”text-align: center;”>  
  4.         &nbsp;&nbsp;  
  5.         <asp:Button ID=”btnAdminUsers” runat=”server” Text=”List Users” PostBackUrl=”" CssClass=”adminButton” />&nbsp;&nbsp;  
  6.         <asp:Button ID=”btnAdminActivate” runat=”server” Text=”Inactive Users” PostBackUrl=”" CssClass=”adminButton” />&nbsp;&nbsp;
  7.         <asp:Button ID=”btnAdminEvents” runat=”server” Text=”Locked Out Users” PostBackUrl=”" CssClass=”adminButton” />&nbsp;&nbsp;                      
  8.         <br /><br />
  9.         &nbsp;&nbsp;   
  10.         <asp:Button ID=”btnAdminRoles” runat=”server” Text=”Roles” PostBackUrl=”" CssClass=”adminButton” />&nbsp;&nbsp;
  11.         <asp:Button ID=”btnAdminAccess” runat=”server” Text=”Access Security” PostBackUrl=”" CssClass=”adminButton” />&nbsp;&nbsp;
  12.         <asp:Button ID=”btnAdminSettings” runat=”server” Text=”Application Settings” PostBackUrl=”" CssClass=”adminButton” />&nbsp;&nbsp;
  13.         <asp:Button ID=”btnAdminReporting” runat=”server” Text=”Reporting” PostBackUrl=”" CssClass=”adminButton” />&nbsp;&nbsp;
  14.         <asp:Button ID=”btnAdminMisc” runat=”server” Text=”Misc” PostBackUrl=”" CssClass=”adminButton” />&nbsp;&nbsp;
  15.     </div>
  16. </asp:Content>

Simple !

Hopefully it will save someone some time.

Technorati Tags: ,,

Taking JetBrains Resharper 5 for a spin.

image

I’ve always found Visual Studio to provide me with all that I need for ASP.NET development, so I’ve never really integrated a significant Add-In to my personal software development process.

But, I keep downloading source code projects that contain ReSharper project files, so I thought I’d give it a try and find out why ReSharper is so popular.

The guys at JetBains hooked me up with the latest version and I was up and running in a few minutes.

In a single statement – ReSharper helps you write better code.

I have to confess, it freaked me out a bit when I first installed it and opened a large existing project.

I got lots of code suggestions like this one.

SNAGHTML5089cd5

I worried that ReSharper would only be good if I were starting from scratch.

I quickly discovered that while I’m learning ReSharper, if it gets in the way at all I can just turn it off while I’m working on a “legacy” project.

SNAGHTML503fdc8

Or, ReSharper makes it easy to implement the suggested changes.

image

Of course you can configure EVERYTHING to suit your taste.

image

From the JetBrains site, here are the highlights of the latest version’s updates.

Compared to previous versions, ReSharper 5 has evolved in four major directions:

  1. Web Development. We have greatly extended the toolset available to ASP.NET developers when they work with markup files and web site infrastructure. ASP.NET MVC developers get a bonus in additional code inspections, syntax highlighting, navigation, and code completion for controllers and actions.
  2. Project Maintenance. ReSharper becomes a valuable assistant not only to individual developers but to teams working with large, complicated projects. It helps them view, change and maintain project structure.
  3. Support for Visual Studio 2010. ReSharper 5 provides support for the new Visual Studio version earlier than ever. Of course, Visual Studio 2005 and 2008 are supported, too.
  4. Code Analysis. This area incorporates several improvements, including “plainly” implementing a substantial pack of new code inspections; the opportunity to get an overview of all code smells in solution; upgrading foreach and for loops to LINQ queries; and letting you track how data values and method calls are passed through your code.
  5. Other enhancements include extended IntelliSense, bookmarking, native NUnit support, and more.

 [ Download a free 30 day trail HERE ]

I’ll update you when I have a couple months of use under my belt.

Technorati Tags: ,,ReSharper,

A simple way to Defend Against Unauthenticated Web Service Access.

Scenario – a developer wants to restrict unauthorized access to a we service in his application.

WARNING: This method is easy but not bulletproof !!!!

The level of security desired is modest and the developer does NOT want to use SSL, WS-* extensions or any other certificate based infrastructure.

A customer emailed be this week with this very question.

They were using the ASP.NET Membership Application Service and Forms based authentication in their application and discovered that the user’s authenticated state in the application was not accessible from his web services.

The problem ?

Web Services (ASMX) and Web Pages (ASPX) can both have session state but they do not SHARE session state.

Here are two quick ways to authenticate calls to Web Service Methods. (There are, of course, many ways.)

First…….

You can pass the UserName and Password to the web service method and manually authenticate.

[ Remember, without SSL the username and password are passed over the web in “clear text” and are theoretically exposed to “man in the middle” interceptions. ]

image

The web service method would look like this….

Code Snippet
  1. [WebMethod]
  2. public string CallWithCredentials(string uname, string pwd)
  3. {
  4.     if (Membership.ValidateUser(uname, pwd))
  5.     {
  6.         return “User IS Authenticated.”;
  7.     }
  8.     else
  9.     {
  10.         return “User NOT Authenticated”;
  11.     }
  12. }

 

And be called like this……

Code Snippet
  1. protected void ButtonCallService_Click(object sender, EventArgs e)
  2. {
  3. MembersOnlyWS.MembersOnly ws = new MembersOnlyWS.MembersOnly();
  4. LabelResults.Text = ws.CallWithCredentials(TextBoxUser.Text, TextBoxPwd.Text);
  5. }

Though this works, it is inelegant because it causes the actual credentials to be passed for each web service method call.

Here is a method that I prefer.

I start by adding a table to my ASPNETDB database, though really you could put it anywhere.

image

Next, I add a LoggedIn event handler to the LoginView control in my site’s MasterPage.

Code Snippet
  1. protected void LoginUser_LoggedIn(object sender, EventArgs e)
  2. {
  3.     Guid newTokenId = new Guid();
  4.     using (ASPNETDBEntities db = new ASPNETDBEntities())
  5.     {
  6.         ServiceToken newToken = new ServiceToken();
  7.         newToken.Token = newTokenId;
  8.         db.AddToServiceTokens(newToken);
  9.         db.SaveChanges();
  10.     }
  11.  
  12.     Session["UserServiceToken"] = newTokenId;
  13. }

 

When the user logs in this code does three things.

1.) Gets a new GUID

2.) Stores that GUID in the ServiceTokens table

3.) Stores the same GUID in a session variable.

Now we re-factor our Web Service method to accept a single parameter (a GUID as a sting) instead of a UserName / Password pair.

Code Snippet
  1. [WebMethod]
  2. public string CallWithToken(string token)
  3. {
  4.     if (token == “” || token == null)
  5.     {
  6.         return “User NOT Authenticated”;
  7.     }
  8.     else
  9.     {
  10.  
  11.         using (ASPNETDBEntities db = new ASPNETDBEntities())
  12.         {
  13.             Guid userGuid = new Guid(token);
  14.             var myToken = (from t in db.ServiceTokens where t.Token == userGuid select t).FirstOrDefault();
  15.             if (myToken != null)
  16.             {
  17.                 return “User IS Authenticated.”;
  18.             }
  19.             else
  20.             {
  21.                 return “User NOT Authenticated”;
  22.             }
  23.         }
  24.     }
  25. }

When the method gets called we take the GUID/Token and see if that GUID exists in the ServiceTokens table.

If the web method does not receive a GUID, or if the GUID received does not exist in the ServiceTokens table, the user is declared as “Not Authenticated”.

How YOUR application handles method calls that fail to provide a valid token will be up to you and will depend on the specifics of your application. IN the case of this demo, we just return an “unauthenticated” message.

Now, in our page code we can call our Web Service Method by retrieving the GUID that we previously stored in a session variable and passing it to the web service method.

Code Snippet
  1. protected void ButtonPreAuthCallService_Click(object sender, EventArgs e)
  2. {
  3.     if (!HttpContext.Current.User.Identity.IsAuthenticated)
  4.     {
  5.         Response.Redirect(“~/Account/Login.aspx”);
  6.     }
  7.  
  8.     MembersOnlyWS.MembersOnly ws = new MembersOnlyWS.MembersOnly();
  9.     if (Session["UserServiceToken"] != null)
  10.     {
  11.         LabelPreAuthResult.Text = ws.CallWithToken(Session["UserServiceToken"].ToString());
  12.     }
  13.     else
  14.     {
  15.         Response.Redirect(“~/Account/Login.aspx”);
  16.     }
  17. }

Notice that if the user is not authenticated or the GUID in the session object is empty, the user gets redirected to the LogIn.aspx page.

In practice this means that our user interface won’t let an unauthenticated user make a web service method call but the web service method itself  could be called directly from outside our application and that’s why we require a valid GUID that is created when a user successfully logs in.

There is one gotcha that we need to address.

Every time a user logs in, a GUID gets added to the ServiceTokens table but those tokens never get removed.

The more the application gets used, the higher the likelihood that a brute force attack could stumble on a valid token and those tokens are valid forever (never deleted from the database.).

To solve this problem we’ll need to delete the tokens from the ServiceTokens table when the user is done with them.

If the user logs out this is easy to do.

We can modify the LogedInTemplate of the LoginView control in our master page to hook an event handler for when the user logs out.

Code Snippet
  1. <LoggedInTemplate>
  2.     Welcome <span class=”bold”><asp:LoginName ID=”HeadLoginName” runat=”server” /></span>!
  3.     [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" OnLoggedOut="RemoveServiceToken" LogoutPageUrl="~/"/> ]
  4. </LoggedInTemplate>

 

Then we can implement that “OnLoggedOut” event handler as so…..

Code Snippet
  1. protected void RemoveServiceToken(object sender, EventArgs e)
  2. {
  3.     using (ASPNETDBEntities db = new ASPNETDBEntities())
  4.     {
  5.         Guid userGuid = new Guid(Session["UserServiceToken"].ToString());
  6.         var myToken = (from t in db.ServiceTokens where t.Token == userGuid select t).FirstOrDefault();
  7.         if (myToken != null)
  8.         {
  9.             db.DeleteObject(myToken);
  10.             db.SaveChanges();
  11.         }
  12.     }
  13.     Session["UserServiceToken"] = “”;
  14. }

 

Note that the UserServiceToken is removed from the Session Object and the ServiceTokens table in the database.

This is fine if the user actually logs out, but what if the user does NOT log out?

We still want to clean up the GUIDs even if the user never logs out.

[ NOTE : the following method only works if session management is “InProc” if we are using alternate session management then we would need a different Session_End strategy. ]

When the session expires, we can clean up the GUIDs as well.

In the Global.asax.cs file ….

Code Snippet
  1. void Session_End(object sender, EventArgs e)
  2. {
  3.     // Code that runs when a session ends.
  4.     // Note: The Session_End event is raised only when the sessionstate mode
  5.     // is set to InProc in the Web.config file. If session mode is set to StateServer
  6.     // or SQLServer, the event is not raised.
  7.         if (Session["UserServiceToken"] != null)
  8.         {
  9.             using (ASPNETDBEntities db = new ASPNETDBEntities())
  10.             {
  11.                 Guid userGuid = new Guid(Session["UserServiceToken"].ToString());
  12.                 var myToken = (from t in db.ServiceTokens where t.Token ==  userGuid select t).FirstOrDefault();
  13.                 if (myToken != null)
  14.                    {
  15.                    db.DeleteObject(myToken);
  16.                    db.SaveChanges();
  17.                    }           
  18.             }
  19.             Session["UserServiceToken"] = “”;
  20.         }
  21. }

Note that there is some subtle logic here.

When the session expires, the LogInView control will still show the user as logged in but when we actually TEST the authentication state of the user in our code-behind ….

Code Snippet
  1. if (!HttpContext.Current.User.Identity.IsAuthenticated)
  2. {
  3.     Response.Redirect(“~/Account/Login.aspx”);
  4. }

The result will be false and the user will be asked to re-authenticate by entering their username and password in order to call the web service method.

This makes our web service method unlikely to be successfully invoked by an unauthorized user because in order to do so, a bad guy would need to either need to intercept a valid set of credentials or guess a GUID that exists in the ServiceTokens table and use it while a valid user is logged on.

Hope someone finds this useful :)

[ Click HERE to download an ASP.NET 4 sample. ]

ASP.NET Membership – Handling Authenticated Users that are Not Authorized.

image

When you create an ASP.NET Web Forms project using the default template, the web.config file specifies where users will “Log In” to the site.

Code Snippet
  1. <authentication mode=Forms>
  2.   <forms loginUrl=~/Account/Login.aspx timeout=2880 />
  3. </authentication>

The template also provides the “Account” directory as seen in the Visual Studio Explorer snapshot above.

Note that the “Account” contains it’s own web.config file which contains the following elements.

Code Snippet
  1. <?xml version=1.0?>
  2. <configuration>
  3.  
  4.   <location path=Register.aspx>
  5.     <system.web>
  6.       <authorization>
  7.         <allow users=*/>
  8.       </authorization>
  9.     </system.web>
  10.   </location>
  11.  
  12.   <system.web>
  13.     <authorization>
  14.       <deny users=?/>
  15.     </authorization>
  16.   </system.web>
  17.  
  18. </configuration>

The Login.aspx page is accessible to all users because it is specified as the LoginUrl for user authentication.

The web.config file is evaluated top-to-bottom.

The authorization element explicitly denies access to all UNAUTHENTICATED users by way of the specification <deny users=”?” /> where the question mark means all unauthenticated users.

However, if the user does not have an account on the web site, they will need access to the “Register.aspx” page in order to create one.

This resources specific access is provided via the <location> element which explicitly grants access to the “Register.aspx” page with the <allow users=”*”  /> where the star means all users, authenticated or not.

All this means that whenever a resource (page / directory) is requested but the user lack the necessary privileges for that resource, the user is redirected to the loginUrl specified in the application’s default web.config file.

In the default ASP.NET Web Forms template this works fine because the only authorization criteria is Logged In or NOT Logged In.

But what if our Authorization criteria is more diverse than that.

ASP.NET Membership makes it easy to configure URL based Authorization based on “ASP.NET Roles” or even for a specific user.

In the snapshot above showing solution in the Visual Studio Solution Explorer, please note 2 new directories.

  1. Admin
  2. SuperUser

The “Admin” folder will contain pages that implement administrative features for our web site, so we need to restrict access so that a user must be BOTH logged in AND a member of the “Administrator” Role Group in order to access the folders contained pages.

Our ”Admin” folder contains a web.config file with a defaul authorization critera that denies access to all users and then specifically GRANTS access to administrators with the element “<allow roles=”Administrator” />

Note that I have also granted access for ALL USERS to the page “AccessDenied.aspx”

Code Snippet
  1. <?xml version=1.0?>
  2. <configuration>
  3.     <location path=AccessDenied.aspx>
  4.         <system.web>
  5.             <authorization>
  6.                 <allow users=*/>
  7.             </authorization>
  8.         </system.web>
  9.     </location>
  10.   <system.web>
  11.     <authorization>       
  12.        <allow roles=Administrator/>  
  13.        <deny users=*/>      
  14.     </authorization>
  15.   </system.web>
  16. </configuration>

This creates an additional user experience challenge for us since a user can be logged in but NOT an Administrator. By default, when Authorization fails for any resource the user is redirected to the loginUrl.

This will be confusing for the user since they are already logged in, they just aren’t part of the “Administrator” role.

To improve the user experience, we’ll add some code to the Load Event of the Login.aspx page to determine whether or not we got there because an already logged in user tried to access a resource in the “Admin”  folder.

If this is the case we’ll redirect them to the “Admin/AccessDenied.aspx” file which is accessible to all users on the web site.

Code Snippet
  1. using System;
  2. using System.Web;
  3. using System.Web.Security;
  4.  
  5. namespace NETOOPWF.Account
  6. {
  7.     public partial class Login : System.Web.UI.Page
  8.     {
  9.         protected void Page_Load(object sender, EventArgs e)
  10.         {
  11.             string test = System.Configuration.ConfigurationManager.AppSettings["SuperUser"];
  12.             if (Request.IsAuthenticated)
  13.             {
  14.                 string mp = HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);
  15.                 if (mp != null)
  16.                 {
  17.                     mp = mp.ToLower();
  18.                     if (mp.IndexOf(“%2fadmin”) > -1)
  19.                     {
  20.                         Response.Redirect(“~/Admin/AccessDenied.aspx”);
  21.                     }
  22.                 }
  23.             }
  24.             RegisterHyperLink.NavigateUrl = “Register.aspx?ReturnUrl=” + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);
  25.         }
  26.     }
  27. }

Here’s the Pseudo Code for the logic :

  • Check is the user is already logged in. If Yes (Then we probably got here due to an unauthorized access attempt ) ……
  • Get a string that contains the relative path to the page that was requests.
  • Find out if the requested page is in the ”Admin” directory. If Yes ….
  • Send the user to the “/Admin/AccessDenied.aspx” page.

Now, if the user requests a resourse in the Admin folder and the user is anonymous then they will be presented with the Login Page.

If they are already logged in but NOT an Administrator, they will see this page.

SNAGHTML19704c8

Note that we can use the same process when implementing user specific authorization.

Note also the folder named “SuperUser” in the Solution Explorer

image

The web.config file in the ”SuperUser” folder contains looks like this.

Code Snippet
  1. <?xml version=1.0?>
  2. <configuration>
  3.     <location path=AccessDenied.aspx>
  4.         <system.web>
  5.             <authorization>
  6.                 <allow users=*/>
  7.             </authorization>
  8.         </system.web>
  9.     </location>
  10.   <system.web>
  11.     <authorization>      
  12.        <allow users=SuperUser/> 
  13.        <deny users=*/>     
  14.     </authorization>
  15.   </system.web>
  16. </configuration>

 

Note that instead of allowing users based on a role, as we did in the “Admin” folder, we deny access to everyone and then explicitly GRANT access to ONLY a specific user who’s User Name is “SuperUser”.

We also have an AccessDenied.aspx page in the “SuperUser” folder that is accessible to anyone.

Next we modify the “Login.aspx.cs” file as follows.

Code Snippet
  1. using System;
  2. using System.Web;
  3. using System.Web.Security;
  4.  
  5. namespace NETOOPWF.Account
  6. {
  7.     public partial class Login : System.Web.UI.Page
  8.     {
  9.         protected void Page_Load(object sender, EventArgs e)
  10.         {
  11.             string test = System.Configuration.ConfigurationManager.AppSettings["SuperUser"];
  12.             if (Request.IsAuthenticated)
  13.             {
  14.                 string mp = HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);
  15.                 if (mp != null)
  16.                 {
  17.                     mp = mp.ToLower();
  18.                     if (mp.IndexOf(“%2fsuperuser”) > -1)
  19.                     {
  20.                         Response.Redirect(“~/SuperUser/AccessDenied.aspx”);
  21.                     }
  22.                     if (mp.IndexOf(“%2fadmin”) > -1)
  23.                     {
  24.                         Response.Redirect(“~/Admin/AccessDenied.aspx”);
  25.                     }
  26.                 }
  27.             }
  28.             RegisterHyperLink.NavigateUrl = “Register.aspx?ReturnUrl=” + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);
  29.         }
  30.     }
  31. }

Since any user who requests a page in the \SuperUser folder and is NOT User Name “SuperUser” will get redirected to the LogIn page we can check to see if the requested resource was in the SuperUser folder.

Since the user named “SuperUser” would have access to all the resources in that folder, we know that the request was directed here because the user was NOT “SuperUser” and therefore is not Authorized.

Then we just redirect the user to the “\SuperUser\AccessDenied.aspx”  page.

SNAGHTML1ad7b9d

Adding ASP.NET Membership to your OWN Database.

ScottGu forwarded me an email from a developer this weekend who wanted to use ASP.NET Membership in an application deployed on a shared hosting account that allows only one SQL Server database.

It’s not all that difficult to add ASP.NET membership (as well as other ASP.NET services) to your existing database.

ASP.NET doesn’t really care where the information repository for it’s built in services live as long as they are complete.

The database that contains the ASP.NET Application Services repository is resolved via a standard connection string in the application’s web.config file.

   1:     <connectionStrings>
   2:      <add name="ApplicationServices"
   3:           connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;                                  

                    AttachDBFilename=|DataDirectory|\aspnetdb.mdf; User Instance=true"
   4:           providerName="System.Data.SqlClient" />
   5:    </connectionStrings>

In the entry above the connection points to the a default database of aspnetdb.mdf in the local application’s App_Data directory.

Note that the default is determined by settings in the machine.config file. If you have run the aspnet_regsql.exe utility on your developer machine to configure a SQL Server database to house the membership / ASP.NET Application Services tables than your machine.config defaults probably point to a SQL Server instance instead of a SQL Express database.

In any event, you can use a connection sting like the one above and simply change the .mdf file name to the one that you need to use in your App_Data folder.

If you are doing this on your shared host that you would specify the connection string to your hosting provider’s database and they would have provided you with the necessary connection information when you signed up for the account.

Once our application can connect to the database we’ve chosen to house out membership information we need to configure our database for use by the Membership Provider.

The ASP.NET installation provides some .SQL script files that we can use to make this process easier.

In Windows Explorer, navigate to your .NET Framework install directory.

On my development machine it was located here.

C:\Windows\Microsoft.NET\Framework\v4.0.30319

Note the highlighted .SQL files in the figure below

ASPSQLServicesCodeFiles

Though all may be useful to you in setting up the various ASP.NET Application Services, for the purposes of this post, we’re only going to set up the ASP.NET Membership service.

We will need the first two .sql files…..

InstallCommon.sql

InstallMembership.sql

Make separate copies of these as we’ll need to edit them before we run them.

Next you need to determine how you will execute T-SQL against your SQL Server instance.

If you are working on your own machine you can simply run SQL Server Management Studio on your machine (or against your SQL Server instance.)

If you’re host does not support direct connections with SQL Server Management Studio then they will likely have provided some web based administration mechanism and you will need to use that to execute the T-SQL.

In my sample application I created an empty SQL Express database named AddedMembershipDemo.mdf

AddedMembershipDemoMDF

First open the copy of InstallCommon.sql  that you made.

You will have to make a couple of edits to the code. You will note several references to the database name “”aspnetdb”……

Here are a few examples:

SET @dbname = N’aspnetdb’

USE [aspnetdb]
GO

You must change all references to “aspnetdb” to the name of the database that you are adding the ASP.NET Application Services to.

Since the database already exists you will want to comment out the code bock that looks like this:

   1: IF (NOT EXISTS (SELECT name

   2:                 FROM master.dbo.sysdatabases

   3:                 WHERE name = @dbname))

   4: BEGIN

   5:   PRINT 'Creating the ' + @dbname + ' database...'

   6:   DECLARE @cmd nvarchar(500)

   7:   SET @cmd = 'CREATE DATABASE [' + @dbname + '] ' + @dboptions

   8:   EXEC(@cmd)

   9: END

  10: GO

Once you have made those changes you should be able to run the resulting script successfully (though you may get a warning about some permission assignments.)

Next open InstallMembership.sql and change the references to aspnetdb to whatever your new database name is and run that script as well.

On success you’re database will contain Tables, Views, Stored Procedures, etc like this.

AddedMembershipDemoMDFTables

If you started your application by creating from the default ASP.NET application template, your web.config file should already have the configuration section for ASP.NET Membership. If not you will need to add it manually as below.

   1: <membership>

   2:   <providers>

   3:     <clear/>

   4:     <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"

   5:          enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"

   6:          maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"

   7:          applicationName="/" />

   8:   </providers>

   9: </membership>

Now you should be able to open your site and start adding users to the membership repository.

Code Snippet : Manually Creating a New ASP.NET Membership User in C#

Though ASP.NET controls are great, in many cases I prefer the power and flexibility of doing things in code. 

I wrote the following code this week as part of a demo I’m working on and thoght I would share it. (Why write all these case statements yourself.)

I hope someone finds it useful.

   1:  public partial class NewUser : System.Web.UI.Page
   2:  {
   3:      protected void Page_Load(object sender, EventArgs e)
   4:      {
   5:       Session["ContinueDestinationPageUrl"] = Request.QueryString["ReturnUrl"];
   6:      }
   7:   
   8:      protected void btnAddUser_Click(object sender, EventArgs e)
   9:      {
  10:          if (Page.IsValid)
  11:          {
  12:              MembershipCreateStatus createStatus;
  13:              string sUserName = tbUserName.Text;
  14:              string sPassword = tbPassword.Text;
  15:              string sEmail = tbEmailAddress.Text;
  16:              string sQuestion = tbSecurityQuestion.Text;
  17:              string sAnswer = tbSecurityAnswer.Text;
  18:   
  19:              MembershipUser newUser = Membership.CreateUser(
                                            HttpUtility.HtmlEncode(sUserName.Trim()),
  20:                                       HttpUtility.HtmlEncode(sPassword.Trim()),
  21:                                        HttpUtility.HtmlEncode(sEmail.Trim()),
  22:                                       HttpUtility.HtmlEncode(sQuestion.Trim()),
  23:                                       HttpUtility.HtmlEncode(sAnswer.Trim()),
  24:                                       true,
  25:                                        out createStatus);
  26:              string CreateResultMessage = "";
  27:              switch (createStatus)
  28:              {
  29:                  case MembershipCreateStatus.Success:
  30:                      CreateResultMessage =
                                  "&raquo; The user was successfully created. &laquo;";
  31:                      break;
  32:                  case MembershipCreateStatus.InvalidUserName:
  33:                      CreateResultMessage =
                                   "The user name was not found in the database.";
  34:                      break;
  35:                  case MembershipCreateStatus.InvalidPassword:
  36:                      CreateResultMessage =
                                   "The password is not formatted correctly.";
  37:                      break;
  38:                  case MembershipCreateStatus.InvalidQuestion:
  39:                      CreateResultMessage =
                                   "The password question is not formatted correctly.";
  40:                      break;
  41:                  case MembershipCreateStatus.InvalidAnswer:
  42:                      CreateResultMessage =
                                  "The password answer is not formatted correctly.";
  43:                      break;
  44:                  case MembershipCreateStatus.InvalidEmail:
  45:                      CreateResultMessage =
                                 "The e-mail address is not formatted correctly.";
  46:                      break;
  47:                  case MembershipCreateStatus.DuplicateUserName:
  48:                      CreateResultMessage =
                                  "The user name already exists in the database
                                                  for the application.";
  49:                      break;
  50:                  case MembershipCreateStatus.DuplicateEmail:
  51:                      CreateResultMessage =
                                  "The e-mail address already exists in the database
                                                  for the application.";
  52:                      break;
  53:                  case MembershipCreateStatus.UserRejected:
  54:                      CreateResultMessage =
                                   "The user was not created, for a reason defined
                                              by the provider.";
  55:                      break;
  56:                  case MembershipCreateStatus.InvalidProviderUserKey:
  57:                      CreateResultMessage =
                                   "The provider user key is of an invalid type or
                                              format.";
  58:                      break;
  59:                  case MembershipCreateStatus.DuplicateProviderUserKey:
  60:                      CreateResultMessage =
                                    "The ProviderUserKey already exists in the database
                                              for the application.";
  61:                      break;
  62:                  case MembershipCreateStatus.ProviderError:
  63:                      CreateResultMessage =
                                "The provider returned an error that is not described
                                                  by other ";
  64:                      CreateResultMessage +=
                                    "MembershipCreateStatus enumeration values.";
  65:                      break;
  66:              }
  67:   
  68:              if (createStatus != MembershipCreateStatus.Success)
  69:              {
  70:                  lblCreateResultMessage.CssClass = "ValidationError";
  71:                  lblCreateResultMessage.Text = CreateResultMessage;
  72:                  btnAddUser.Visible = true;
  73:                  divResultMessage.Visible = true;
  74:              }
  75:              else
  76:              {
  77:                  lblCreateResultMessage.CssClass = "bold";
  78:                  btnAddUser.Visible = false;
  79:                  FormsAuthentication.SetAuthCookie(newUser.UserName, false);
  80:   
  81:                  string continueUrl =
                              Session["ContinueDestinationPageUrl"].ToString();
  82:                  if (String.IsNullOrEmpty(continueUrl))
  83:                  {
  84:                      continueUrl = "~/";
  85:                  }
  86:                  Response.Redirect(continueUrl);
  87:              }
  88:   
  89:          }
  90:      }
  91:   
  92:  }

Technorati Tags: ,,,

Sometimes you need to dig in a little to get things to work the way that you want.

I’m working on an events calendar and I need specific behavior for the home page display.

When the page initially renders, I want to display a list of events in the current month.

Then, I want to modify the display based on the user’s interaction.

  • If the user picks a date then I want to display only the events on that day.
  • If the user navigates to a different month I want to display the events for that month, even if they previously choose a specific day.

To do this I need to do the equivalent of a SQL SELECT based on EITHER the Day or the Month depending on the users choices.

7-2-2010 8-40-19 AM

The code for this was easy but figuring out exactly what to do in relation to the controls behavior took a few minutes to straighten out.

The Calendar Control has a SelectedDate property but until a user chooses a specific DAY it’s values is 01/01/0001. (Meaning if you evaluate the properly in the Load Event it has not been set to anything.)

Clicking on the next or previous month links do not change the SelectedDate property. If the user never selected a date it’s still 01/01/0001 and if the user has previously selected a date, changing the current month has no effect on the SelectedData property either.

It’s easy to understand why this is the case if you view the Calendar Control as a “Date Picker”.

My answer came in leveraging the various events thrown by the control.

The Calendar has a VisibleDate property that contains a DateTime object who’s value is set to the first day of the Month being displayed in the calendar control. This property is updated whenever the user changes the month whether they have selected a specific day or not.

Unfortunately, the VisibleDate property is not set by default. (Meaning if you evaluate the properly in the Load Event it has not been set to anything.)

Here is the simple code I’m using to get the date “type” (Month or Day) and the value to use for the SQL Parameter based on the state of the control and the user’s interaction.

Code Snippet
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7.  
  8. namespace CalendarDrivenSelect
  9. {
  10.     public partial class _Default : System.Web.UI.Page
  11.     {
  12.         DateTime usableDate;
  13.  
  14.         protected void Page_Load(object sender, EventArgs e)
  15.         {
  16.             if (!IsPostBack)
  17.             {
  18.                 usableDate = SelectCalendar.TodaysDate;
  19.                 TextBox1.Text = usableDate.Month.ToString();
  20.             }
  21.         }
  22.  
  23.         protected void SelectCalendar_SelectionChanged(object sender, EventArgs e)
  24.         {
  25.             usableDate = SelectCalendar.SelectedDate;
  26.             TextBox1.Text = usableDate.ToString();
  27.         }
  28.  
  29.         protected void SelectCalendar_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
  30.         {
  31.             usableDate = SelectCalendar.VisibleDate;
  32.             TextBox1.Text = usableDate.Month.ToString();
  33.         }
  34.     }
  35. }

 

If the page is not a postback, I use the Control’s TodaysDate value then whenever the user makes a change I take action in the event handler for the “type” of change that they make. If they select a specific date, I extract that date. If they later select a different month to display I extract that Month and that selection overrides the previously selected date.

In the code above I’m just populating a text box but in the application code I will use that value to set the actual Events SELECT criteria.

A simple solution but not immediately obvious.

Hope it helps someone.

Technorati Tags: ,,

Making ASP.NET Buttons Match the default WebSite Template.

6-30-2010 10-42-02 AM

 I’m working on a couple of demo application in ASP.NET Web Forms and I noticed that, like in many themes I encounter, Button objects don’t match the theme and lack mouseover effects.

So here is how you make your ASP.NET Button control instances match other “clickable” objects in the default ASP.NET Web Site template (like the menu tab).

Open the Site.css file in the Styles folder of your solution and add the following 2 CSS classes.

Code Snippet
  1.  
  2. .button {   
  3.    color: White;   
  4.    background-color: #465C71;
  5.    border:1px solid;   
  6.    border-color: Gray;   
  7. }   
  8.  
  9. .buttonhover {   
  10.    color: White;   
  11.    background-color: #BFCBD6;
  12.    border:1px solid;   
  13.    border-color: Gray;   
  14. }

Now when you add an ASP.NET Button Control to your page, set the CssClass to button and add html onmouseover and onmouseout attributes as follows.

 

Code Snippet
  1.  
  2. <asp:Button ID="Button1" runat="server" Text="Button" CssClass="button"
  3.             onmouseover="this.className=’buttonhover’"
  4.                          onmouseout="this.className=’button’"  />
  5.  

 

By default your buttons still look like vanilla buttons but when you want, this method will make your buttons match your site’s theme.

 

Technorati Tags: ,,

5 More Tailspin Spyworks Videos Now Live

6-29-2010 1-18-56 PM

The www.asp.net content team ahs pushed 5 more of my Tailspin Spyworks sample application videos live for your viewing pleasure.

TailSpin SpyWorks – Adding Items to the Shopping Cart

TailSpin SpyWorks – Display Shopping Cart

TailSpin SpyWorks – Update the Shopping Cart

TailSpin SpyWorks – Migrate the Shopping Cart

TailSpin SpyWorks – Final Check Out

Work continues …….

Add your recent Tweets to your web site.

image

Twitter continues to gain in popularity, in part because it offers a rich and easy to use query API.

Just for fun I made an ASP.NET Web Forms User Control to Display some recent Tweets on a web page.

The tweets are displayed in a ListView as follows.

Code Snippet
  1. <%@ Control Language=”C#” AutoEventWireup=”true” CodeBehind=”MyTweets.ascx.cs” Inherits=”NETOOP.Controls.MyTweets” %>
  2. <%@ OutputCache Duration=”3600″ VaryByParam=”None” %>
  3.     <asp:ListView ID=”MyTweetsListView” runat=”server”>
  4.         <LayoutTemplate>
  5.             <table class=”gridview”>
  6.                 <th>My Tweets</th>
  7.                 <tbody>
  8.                     <asp:PlaceHolder ID=”itemPlaceholder” runat=”server” />
  9.                 </tbody>
  10.             </table>
  11.         </LayoutTemplate>
  12.         <ItemTemplate>
  13.             <tr>
  14.                 <td><a href=’<%#Eval(“Url”)%>‘><%#Eval(“Title”) %></a></td>
  15.             </tr>
  16.         </ItemTemplate>
  17.     </asp:ListView>

Note the use of the OutputCache directive so the Twitter API doesn’t need to get called for very single request of any page that contains this control.

Since Microsoft’s .NET is so XML savvy and LINQ to XML is so powerful the C# code to fetch the tweets and bind to the ListView is pretty straight forward.

Code Snippet
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Xml.Linq;
  8.  
  9. namespace NETOOP.Controls
  10. {
  11.     public partial class MyTweets : System.Web.UI.UserControl
  12.     {
  13.         protected void Page_Load(object sender, EventArgs e)
  14.         {
  15.             XNamespace slashNamespace = “http://purl.org/rss/1.0/modules/slash/”;
  16.  
  17.             XDocument rssFeed = XDocument.Load(“http://www.twitter.com/statuses/user_timeline/misfitgeek.rss” + “?count=5″);
  18.  
  19.             var posts = from item in rssFeed.Descendants(“item”)
  20.                         select new
  21.                         {
  22.                             Title = item.Element(“title”).Value,
  23.                             Url = item.Element(“link”).Value,
  24.                         };
  25.  
  26.             MyTweetsListView.DataSource = posts;
  27.             MyTweetsListView.DataBind();
  28.         }
  29.     }
  30. }

 

Notice that he URL in the XDocument.Load specifies “misfitgeek.rss” to pull my personal tweets (which you can include on your web site if you like). You could change the portion of the URL to reflect your own Twitter name.

Technorati Tags: ,,

Alachisoft’s new version of NCache announced at TechEd !

Before coming to Microsoft I owned a consulting company that specialized in solving performance and scalability problems in web applications.

It always amazed me how many seeming huge problems could be solved with a little strategic caching implementation.

Alachisoft’s NCache is a PREMIER provider of advanced caching technology for ASP.NET.

Though ASP.NET has caching functionality built in, NCache can help you take caching in your application to the next level.

Here are some of the NEW features.

  • Dashboard Style Monitoring Tool: With this tool, you can now monitor all aspects of your cache and application live. You get a dashboard which can be customized according to your monitoring needs.
  • LINQ Support: NCache now provides LINQ integration with IQueryable interface that makes cached items searchable.
  • Entity Framework (EF) Caching: Now you can do seamless integration with EF caching. Plug in at the ADO level and use NCache caching without any code changes.
  • .NET Cache Provider 4.0: Integration with .NET Cache provider 4.0 – with Change Monitors (file based, key based, database dependency) for managing cache dependencies.
  • Streaming API: With streaming support in the API, now you can read and write binary data stream in the cache.
  • Multiple Providers for ReadThru/WriteThru: Develop multiple ReadThru/WriteThru providers and register with NCache. You can use a specific provider from each of your application..
  • Dynamic ReadThru/WriteThru Deployment: Use NCache Manager to deploy your ReadThru/WriteThru handlers even at runtime. Your assemblies are automatically copied to all the cache servers.
  • Runtime Compact Serialization (no programming needed): Use a faster and more compact serialization than regular .NET serialization and without writing any custom code for it. NCache generated serialization code at runtime and even lets you serialize objects that are otherwise not serializable.
  • ViewState Caching: Cache ViewState at your web server and reduce the payload being returned to the browser and speed up response time.
  • Merge & Minify Javascript/CSS: Minify and merge multiple JavaScript files. This reduces the payload sent to the browser and also the number of HTTP calls the browser makes to the web server. The results is faster response time.
  • Protocol-level Backward Compatibility for Clients: NCache 3.8 offers protocol-level backward compatibility from now on. This means any future upgrades would be 100% backward compatible at protocol-level.
  • Remote Client Management from NCache Manager: Configure Remote Clients from NCache Manager and easily change individual client settings all from a single point.

One of the especially cool things about NCache is the FREE Express version (Limited to 2-server clusters with local clients) – this lets you prove your strategy before spending anything but time :)

You can get started by going to http://www.alachisoft.com/

Can not Load Type – Starting the ASP.NET Web Site Admin Tool

SNAGHTMLd7e063

A beginner emailed me last night and I had forgotten about this little ditty !

When you create a NEW project and immediately try to run the Web Site Administration Tool you will get this error.

The solution is easy – BUILD FIRST !

I remember being very confused the first time I got this :)

First 3 Videos – Building Tailspin Spyworks

image

I’ve published the first three videos on a follow-a-long series on building the Tailspin  Spyworks demo application.

More Every Week !

http://www.asp.net/web-forms/samples/tailspin-spyworks

 

Technorati Tags: ,WebForms,,

Embedding the Silverlight version of the Open Media Player

image

I’m working on a Video Portal Application and have selected the Open Video Player for embedded viewing of videos.

There are many video players out there but I selected this one becuase there are SilverLight and Flash versions in the project.

Embedding is EASY !

Code Snippet
  1. <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
  2.     CodeBehind="Default.aspx.cs" Inherits="OpenPlayerSample._Default" %>
  3.  
  4. <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
  5. </asp:Content>
  6. <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
  7.     <h2>
  8.         Welcome to ASP.NET!
  9.     </h2>
  10.     <p>
  11.         To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.
  12.     </p>
  13.     <p>
  14.         <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="600px" id="slp" >
  15.             <param name="source" value="./Player/SL/OVP.xap"/>
  16.             <param name="minRuntimeVersion" value="2.0.30923.0" />
  17.             <param name="onerror" value="onSilverlightError" />
  18.             <param name="background" value="black" />
  19.             <param name="MaxFrameRate" value="30" />
  20.             <a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">
  21.             <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/></a>
  22.             <param name="initparams" value=’showstatistics=true,
  23.                                             autoplay=false,
  24.                                             muted=false,
  25.                                             playlistoverlay=false,
  26.                                             theme=/Player/Themes/ShinyBlue.xaml,
  27.                                             stretchmode=Fit,
  28.                                             stretchmodefullscreen=Fit,
  29.                                             mediasource=http://misfitgeek.com/not_a_real_video.wmv’ />
  30.         </object>
  31.     </p>
  32. </asp:Content>

 

Stay tuned to my blog for more usage context in the near future.

 

Archiving your contact form data.

image

I get TONS of email from customer.

Over time, this email helps me to determine what areas in our product collection are opportunities for enhancement or improvement.

I store the email that comes from my blog contact form in folders and then search through them looking for trends periodically.

It occurred to me that, while I need to get the emails because many of them are actionable, it would be great if I could use reporting and analysis tools against the collection.

So I whipped together a sample in ASP.NET MVC

I set up a simple SQL Express database and use Visual Studio to generate an EntityDataModel for it.

I implemented the view above and an ActionResult for HttpPost events from the ContactUs view.

Code Snippet
  1. [HttpPost]
  2. public ActionResult ContactUs(Message msg)
  3. {
  4.     if (ModelState.IsValid)
  5.     {
  6.         // Same the Message in the Massages Table.
  7.         try
  8.         {
  9.            using(ContactMailEntities db = new ContactMailEntities())
  10.            {
  11.                db.AddToMessages(msg);
  12.                db.SaveChanges();                  
  13.            }
  14.         }
  15.         catch
  16.         {
  17.             // Store Failed.
  18.             return View(msg);
  19.         }
  20.  
  21.         // Send the Message in email.
  22.         if (!SendMailMessage(msg))
  23.         {
  24.             // Send Failed.
  25.             return View(msg);
  26.         }
  27.     }
  28.     else
  29.     {
  30.         return View(msg);
  31.     }
  32.  
  33.     // Success
  34.    return View("MessageSent");
  35. }

Since my view uses that model, on post back my ActioResult can just create an instance of the model and call the generated “AddToMessages” (to insert to the Messages Table)  method and pass in the Message instance from the View.

Wow – easy and elegant.

BTW the SendMailMessage method looks like this.

Code Snippet
  1. public bool SendMailMessage(Message msg)
  2. {
  3.     try
  4.     {
  5.         MailMessage mailMsg = new MailMessage();
  6.         mailMsg.To.Add("Joe@Stagner.net");
  7.         MailAddress mailAddress = new MailAddress(msg.FromEmail, msg.FromName);
  8.         mailMsg.From = mailAddress;
  9.         mailMsg.Subject = msg.Subject;
  10.         mailMsg.Body = msg.ContactMessage;
  11.  
  12.         SmtpClient smtpClient = new SmtpClient("mail.stagner.net", 2525);
  13.         System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("Joe@Stagner.net", "bingo117");
  14.         smtpClient.Credentials = credentials;
  15.  
  16.         smtpClient.Send(mailMsg);
  17.         return true;
  18.     }
  19.     catch (Exception ex)
  20.     {
  21.         return (false);
  22.     }
  23.  
  24. }

Hope someone finds it useful.

[ Full project HERE ]

 

 

 

Introducing – TailspinSpyworks – WebForms Sample Application

Tailspin-Spyworks-Thumb

iBuySpy was a very popular sample application, but a lot has changed in Web Forms development since then.

ScottGu suggested that I rewrite the old iBuySpy application – so I did.

It’s ASP.NET 4 with CSS based layout, data access via Entity Framework, etc.

The www.asp.net landing page is here http://www.asp.net/web-forms/samples/tailspin-spyworks/

I’ll be adding features over time and doing videos to explain some of the cool stuff.

You can download the code from CodePlex at http://tailspinspyworks.codeplex.com/

For you MVC folks, my team mate (Jon Galloway) has built a sample MVC Store application which you can find here : http://www.asp.net/mvc/samples/mvc-music-store/

 

Technorati Tags: ,,WebForms,

First 3 ASP.NET MVC for the Rest of Us Videos

Folks have been asking me for some time to do some ASP.NET MVC videos 

Here are the first three. They start from the beginning and frequently compare ASP.NET MVC with concepts that you may already be familiar with from WebForms programming.

Enjoy! More to come.

ASP.NET MVC For the Rest of Us: Part 1

37 minutes

ASP.NET MVC For the Rest of Us: Part 2

31 minutes

ASP.NET MVC For the Rest of Us: Part 3

16 minutes

http://www.asp.net/mvc/fundamentals/

 

Technorati Tags: ,

Join me on MSDN Radio next Monday – Mark your calendar.

Announcement:

MSDN Radio: The ASP.NET Developer Evolved with Joe Stagner

Event ID: 1032448575

 

Date: Monday, April 12, 2010 9:00 AM Pacific Time (US & Canada) 30 Minutes

 

Event Overview

You may know him as Mr. How Do I with Microsoft ASP.NET. For the last few years Joe has been busy working with the ASP.NET product team to simplify and educate developers on what’s possible with the latest web tools. We talk with Joe about how the web developer is able to learn about and leverage new tools and techniques for building great solutions.
MSDN Radio is a weekly Developer talk-show that helps answer your questions about the latest Microsoft news, solutions, and technologies. We dive into the challenges of deciphering today’s technology stack. Register today and have a chance to call-in and talk with the experts on the air, or just tune in to the show.
Caller space is limited, dial-in information will be given out during the show.

Presenters: Mike Benkovich, Senior Developer Evangelist, Microsoft Corporation and Joe Stagner, Senior Program Manager, Microsoft Corporation

Mike Benkovich delivers technical presentations around the U.S. as a developer tools evangelist on the MSDN team at Microsoft. He has worked in a variety of professional roles, including architect, project manager, developer, and technical writer. Mike is also a published author with WROX Press and APress, exploring how developers get the most from their SQL databases. Since appearing in the 1994 Microsoft DevCast, Mike has presented technical information at seminars, conferences, and corporate boardrooms across America.

Joe Stagner works at Microsoft with the Developer Tools and Platforms team and as spent almost ten years at Microsoft working with the developer community. With three decades of software development experience, Joe is well versed in the needs of all types of software developers and in recent years has focused on all aspects of web development technology and the use of the world wide web for business and social interaction. In addition to Microsoft’s ASP.NET technology Joe focuses on integrating .NET with third part technology like PHP, Java, etc. You can read his blog at www.misfitgeek.com.

View other sessions from: MSDN Radio

If you have questions or feedback, contact us.

Registration Options

Event ID:
1032448575

Registration page for MDSN Radio on 4/12 is here -  http://tinyurl.com/msdnradio-4

Non-Embedded Content for your Popup Control’s Target Container

Yesterday I posted about client side predicates for Popup controls. Thanks for all the Tweets and Emails.

The Popup control is very powerful and Popups are now an expected construct in many web user interfaces.

I received a number of questions about using content in Popups that is not embedded in the containing page.

Probably the easiest is to use in iFrame inside the Panel container for the Popup.

In code it looks like this.

Code Snippet
  1. <h1>Modal iFrame</h1>
  2. <asp:Button ID="ButtonIFrame" runat="server" Text="Button" /><br /><br />
  3. <div>
  4.     <asp:Panel ID="PaneliFrame" runat="server" CssClass="modalPopup"
  5.                                 Style="display: none" Width="450px" Height="250px">
  6.     <iframe name="f1" src="Popup.aspx"  frameborder="0" scrolling="no" width="100%" height="200px">
  7.     </iframe>
  8.     <br />
  9.        <div align="center">
  10.           <asp:Button ID="OkButton" runat="server" Text="OK" />
  11.           <asp:Button ID="CancelButton" runat="server" Text="Cancel" />
  12.        </div>
  13.     </asp:Panel>
  14.     <br />
  15.    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderIF" runat="server"
  16.              TargetControlID="ButtonIFrame"
  17.              PopupControlID="PaneliFrame"
  18.              BackgroundCssClass="modalBackground"
  19.              DropShadow="true"
  20.              OkControlID="OkButton"
  21.              OnOkScript="onOk()"
  22.              CancelControlID="CancelButton" />
  23. </div>

There is an advantage when using the iFrame in that you can reference a complete HTML or ASPX page since the iFrame expects this.

IN the example above I set the href attribute of the iFrame to a .aspx page (Popup.aspx) in the same solution but you need not do this. The href attribute can be set to any url that you like, even on a different domain.

This avoids an issue that we will need to consider when using the other three methods that I will discuss below.

HTML and ASP.NET both have requirements that define “well formedness”. HTML, for example, declares that a page may only have one <head> section. ASP.NET declares that a page may only have <form> tag with a “runat=server” attribute.

We need to consider this when “inserting” content into our page elements (such as the container that is displayed whern a Popup is shown.

Next lets look at using an ASP.NET User Control in a Popup.

Code Snippet
  1. <h1>Modal Control</h1>
  2. <asp:Button ID="ButtonControl" runat="server" Text="Button" /><br /><br />
  3. <div>
  4.     <asp:Panel ID="PanelControl" runat="server" CssClass="modalPopup"
  5.                                  Style="display: none" Width="450px" Height="250px">
  6.    <uc1:ControlForPopup ID="ControlForPopup1" runat="server" />
  7.  
  8.        <br />
  9.        <div align="center">
  10.           <asp:Button ID="ButtonOkControl" runat="server" Text="OK" />
  11.           <asp:Button ID="ButtonCancelControl" runat="server" Text="Cancel" />
  12.        </div>
  13.     </asp:Panel>
  14.     <br />
  15.    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderControl" runat="server"
  16.              TargetControlID="ButtonControl"
  17.              PopupControlID="PanelControl"
  18.              BackgroundCssClass="modalBackground"
  19.              DropShadow="true"
  20.              OkControlID="ButtonOkControl"
  21.              OnOkScript="onOk()"
  22.              CancelControlID="ButtonCancelControl" />
  23. </div>

This method works pretty much as you would expect with the use of any User Control, and you need to be careful with things like code based rendering (Response.Write), just like any other User Control

Or, we could use the #include directive as below..

Code Snippet
  1. <h1>Modal Include</h1>
  2. <asp:Button ID="ButtonInc" runat="server" Text="Button" /><br /><br />
  3. <div>
  4.      <asp:Panel ID="PanelInc" runat="server" CssClass="modalPopup"
  5.                               Style="display: none" Width="450px" Height="250px">
  6.         <!–#include file="inc_popup.aspx"–>
  7.  
  8.        <br />
  9.        <div align="center">
  10.           <asp:Button ID="ButtonOK_Inc" runat="server" Text="OK" />
  11.           <asp:Button ID="ButtonCancel_Inc" runat="server" Text="Cancel" />
  12.        </div>
  13.     </asp:Panel>
  14.     <br />
  15.    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderInclude" runat="server"
  16.              TargetControlID="ButtonInc"
  17.              PopupControlID="PanelInc"
  18.              BackgroundCssClass="modalBackground"
  19.              DropShadow="true"
  20.              OkControlID="ButtonOK_Inc"
  21.              OnOkScript="onOk()"
  22.              CancelControlID="ButtonCancel_Inc" />
  23. </div>

I’m including a file with a .aspx extension but it is not (nor can it be) a complete ASP.NET page for the reasons stated above.

Lastly, you could fetch the content to be displayed in the Popup on demand via a JavaScript callable services method as shown in this video -

AJAX Content Fetch from JavaScript

Grab a working sample here http://misfitgeek.com/downloads/code/ModalPopup-ExternalSource.zip 

Have fun !

Technorati Tags: ,

ASP.NET AJAX Modal Popup on Mouse Over

Today’s customer question concerns client side predicates for showing a Modal Popup control.

I’m happy to be getting these kind of questions because it shows how ASP.NET developers are continuing to evolve their web development perspective and separate server logic execution and client logic execution.

Though the Modal Popup Extender is a Server Side control extender it HAS client side events and methods. This exposes the Modal Popup to any JavaScript coding that we want.

Example – mouseover !

Code Snippet
  1. <a href="" onmouseover="myMouseOver();">
  2. <img runat="server" id="rollover" alt="" src="image.jpg" border="0" name="rollover" /></a>
  3. <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
  4.           TargetControlID="rollover"
  5.           PopupControlID="Panel1"
  6.           BackgroundCssClass="modalBackground"
  7.           DropShadow="true"
  8.           OkControlID="OkButton"
  9.           OnOkScript="onOk()"
  10.           CancelControlID="CancelButton" />

Note that the TargetControlID is the Image of the anchor tag and the onmousover event handler calls my custom JaqvaScript function myMouseOver() which displays the Modal Popup as follows:

Code Snippet
  1.     <script type="text/javascript">
  2.     var MakeChoice;
  3.     function onOk() {
  4.     // Do stuff Here.
  5.     }
  6.     
  7.     function myMouseOver() {
  8.         $find("ModalPopupExtender1").show();
  9.     }
  10.  
  11. </script>

Click OK or Cancel closes the Modal Popul as you would expect.

Viola !

Bur don’t stop there – use more client side logic to customize the user experience. For example, you could automatically display the Pop Up on Mouse Over and start a timer to count down and hide it again ( $find(“ModalPopupExtender1”).hide(); ) after a certain number of seconds.

Keep making your UIs ROCK !

You can download a runnable sample [ HERE ]

Technorati Tags: ,

Podlogger – Half Baked Code, but yours for free.

image

Some time ago I started building a demo application that would have been posted on www.asp.net.

It is a Podcast Publishing application and completing “basic” functionality we decided that it was a bit too complex for the intended introductory material.

Though not finished (Meaning NOT FINISHED, INCOMPLETE, IMPERFECT, ETC) I thought I’d share it in case anyone finds it useful.

Some of the stuff that is in there :

  • Basic Post Publication with Rich Editor
  • File Upload
  • Comments Submission
  • RSS Feed Publication
  • Integrated Silverlight Audio Player
  • Basic Admin

This code is NOT supported and NOT offered as best practice.

It’s simply a prototype that I’m sharing in case anyone finds it useful.

If you use it anywhere, please let me know what you grow it in to.

[ Click HERE to get the code. ]

Dynamic User Specific CSS Selection at Run Time

I had a cool question while I was at MIX.

A developer needed the ability to have his site render pages using a CSS file selected based on some user specific criteria.

ASP.NET 4 controls generate CSS friendly output and more and more we web developers are using CSS for layout etc.

Using multiple CSS files in our site wide templates we can not only provide different aesthetic experiences but we can charge the style based on the device type (Printer or Phone) or the special needs of the end user (Color Blind of Vision Impaired).

It’s really easy.

I set the Theme Directory yin the Session Start Event Handler.

Though I’, simply setting to a static value here, this is were you would make some decisions in code. You could check for a cookie or the device type.

If you want to make the CSS user selectable you might use a default CSS file until the user logs in and then set this Session Object in the Log In event handler.

protected void Session_Start(object sender, EventArgs e)
{
Session["Theme"] = "Default";
}

Make sure your login never fails to set this value. If you’re depending on a Profile setting or Cookie Value, make sure you have a default setting do that it’s never empty.

Then you can just reference it dynamically in the Style Sheet inclusion of your Mast Page file like this.

 

<link href="/Styles/<%= Session["Theme"] %>/Site.css" rel="stylesheet" type="text/css" />

Simple, but useful.

Did you miss the IIS7 FastCGI Update ?

In case you did, there are some interesting improvements like….

  • Monitor changes to a file. The module can be configured to listen for file change notifications on a specific file and when that file changes, the module will recycle FastCGI processes for the process pool. This feature can be used to recycle PHP processes when changes to php.ini file occur. To enable this feature use the monitorChangesTo setting in the <fastCgi> configuration element.
  • Real-time tuning of MaxInstances setting. This MaxInstances setting dictates the maximum number of FastCGI processes which can be launched for each application pool. Set it to 0 to let FastCGI module automatically adjust the number of instances up or down based on the system load and number of requests waiting in the queue.
  • STDERR stream handling. There are several options of how the module can handle text sent by FastCGI application on STDERR. The module can send the error data as a failure response to the HTTP client or it can ignore the error and send whatever was received on STDOUT as a response with 200 status code. This behavior is controlled by the stderrMode setting.
  • Sending a termination signal to FastCGI processes. The module can be configured to send a termination signal to FastCGI process before terminating it. This enables FastCGI processes to do a clean shutdown before getting killed. The signalBeforeTerminateSeconds setting can be used to specify how long the module will wait before it forcefully shuts down the FastCGI process that does not respond to the termination signal. This feature is disabled by default.
  • _FCGI_X_PIPE_ environment variable. This variable is set by FastCGI module and it contains the name of the named pipe that is used for communication between the module and FastCGI process.
  • Relaxed enforcement of response headers syntax. The FastCGI module now has less strict enforcements for the correctness of the response headers.
  • Using UTF-8 encoding for server variable values. By default FastCGI uses ASCII encoding when setting server variables. If a FastCGI application requires UTF-8 encoded values for certain server variables, the module can be configured to use UTF-8 only for required server variables. Follow these instructions to enable this functionality.

 

Get the update with the “Web Platform Installer” here – http://www.iis.net/webpi

Session Time Out Tricks

I recently received an email from a developer who needed to implement a behavior around a user’s session timeout behavior.

As you probably know, we can configure our application to “expire” a user’s session at any interval that we wish.

Example:

<system.web>
<sessionState timeout="10" />
........
</system.web>

We can add a specification to our application’s web.config file to change the default session expiration time from 20 minutes to a time span of our own choosing. (10 minutes in the example above.)

The session timeout value is a sliding value; on each request the timeout period is set to the current time plus the timeout value.

This means that if a user submits a request after the timeout period expires, the session will have been terminated and the user will no longer be authenticated. If the user’s “post-back” is requesting a secured resource, they will be redirected to the “login” page since the application sees this request as from an anonymous user. (When a session expires the user is de-authenticated.)

The problem in this cast is that the application requirements required that the user be AUTOMATICALLY redirected when the session times out.

This is a sound security practice in certain applications.

For example, lets suppose the application’s user has displayed the results of a query of “sensitive” information. If the user then walks away from their PC, that sensitive data will stay displayed indefinably.

The application that I was contacted about needed the user’s browser to be automatically be redirected when the session timed out.

The problem, of course, is that browser based applications are innately stateless sine they run on HTTP ( a stateless protocol). The browser (client) and the sever only communicate when the CLIENT specifically makes a request of the server.

To meet the applications requirements we can add a timer in JavaScript to be run in the browser.

In our master page (so that the JavaScript will be included in, and executed by every page in our application) we can include the following client side script:

   1:  <head runat="server">
   2:      <title></title>
   3:      <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
   4:      <script type="text/javascript" language="javascript">
   5:      <!--
   6:              var secs
   7:              var timerID = null
   8:              var timerRunning = false
   9:              var delay = 1000
  10:   
  11:              function InitializeTimer() 
  12:              {
  13:                  if (typeof HeadLoginName != 'undefined') {
  14:                  // Set the length of the timer, in seconds
  15:                  secs = 630
  16:                  StopTheClock()
  17:                  StartTheTimer()    
  18:                  }
  19:              }
  20:   
  21:              function StopTheClock() 
  22:              {
  23:                  if (timerRunning)
  24:                      clearTimeout(timerID)
  25:                  timerRunning = false
  26:              }
  27:   
  28:              function StartTheTimer()
  29:              {
  30:                  if (secs == 0) 
  31:                  {
  32:                      StopTheClock()
  33:                      window.location = "default.aspx"
  34:                  }
  35:                  else 
  36:                  {
  37:                      self.status = secs
  38:                      secs = secs - 1
  39:                      timerRunning = true
  40:                      timerID = self.setTimeout("StartTheTimer()", delay)
  41:                  }
  42:              }
  43:      //-->
  44:      </script>
  45:   
  46:      <asp:ContentPlaceHolder ID="HeadContent" runat="server">
  47:      </asp:ContentPlaceHolder>
  48:  </head>

Then we add an “onload” to our html body tag as so:

<body onload="InitializeTimer()">

Note that the client side timer is set to 10 minutes and 30 seconds. This is a plus 30 second complement to the server side setting of 10 minutes so that we should be sure that when the client code “times out” the session on the server will have already expired.

When the client side timer counts down to zero this line of JavaScript code:

  33:                      window.location = "default.aspx"

causes the browser to request the application’s default page.

We could, of course, just post back to the “current” page and let the application’s authentication configuration redirect the user to the application’s login page.

Note that this method is a loose synchronization of the applications session. If we absolutely needed an exact synchronization we could implement an AJAX service method and query the server as to whether or not the REAL .NET session has expired, but we’re not going to do that here since it creates some unnecessary (for most applications)  http traffic.

We could of course do other things form our client side code and do things like black the browser window and pop up a dialog (like a screen saver) or really whatever we want. jQuery is great for this kind of powerful client side work.

Here is a quick bit of sample code that shows the technique – [ DOWNLOAD HERE ].

 

Technorati Tags: ASP.NET Sessions Tips & Tricks

DiscountASP.NET Adds & Enhanced Microsoft IIS Database Manager Support

Historically, working with databases on shared hosting accounts has been problematic.

DiscountASP.net has implemented the IIS Database manager with some additions. Now you can manage your own databases and do things like Backup & Restore yourself.

[ For more information about the IIS Database Manager, and other cool IIS Extensions – Click HERE ]

[ For more info about DiscountASP.NET’s DB Manager Integration -  Read HERE ]

Postback Text Processing with the AJAX Modal Dialog

image

I’ve started blogging simple tips when I get a question from a developer that’s a bit tricky.

This is one of those. Simple to do, but not always simple to find the answer.

In this case the developer wanted to use an AJAX Editor Control inside a ModalPopup control.

This isn’t a problem but, the user needed to clicking the OK button to cause a post-back so that he could execute some server –side logic.

The ”Ok” Button is an ASP.NET control but adding a Click Event Handler for the button didn’t solve the problem because it didn’t get executed when the use Clicked on the “Ok” button.

Normally the ModalPopupExtender would be used like this.

<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="LinkButton1"
PopupControlID="Panel1"
BackgroundCssClass="modalBackground"
DropShadow="true"
1.)         OkControlID="OkButton"
2.)         OnOkScript="onOk()"
CancelControlID="CancelButton" />

Line number 1 tells the control to catch the click event for the Ok Button Control instance and line 2 specifies when CLIENT SIDE JavaScript code to execute when the control specifies in line 1 is clicked.

The post-back doesn’t happen (even if the ASP.NET Button control hasd a click event handler defined in code behind because the control doesn’t propagate it.

So Just delete those two lines !

It turns out that they are optional and if you delete them the click event is not trapped and the code behind will execute as expected.

So just nake it look like this:

<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="LinkButton1"
PopupControlID="Panel1"
BackgroundCssClass="modalBackground"
DropShadow="true"
CancelControlID="CancelButton" />

Simple !

[ Download working C# Code HERE ]

Technorati Tags: ASP.NET AJAX Tips & Tricks

Site Authentication Required, Except Default.aspx

What happens when you need to protect your whole site so that only Authenticated users can access our site.

Since I received this question twice this week I thought I’d share a tip.

To allow ONLY authenticated access to your site using Forms authentication you can add a section like this on e to your application’s web.config file.

<authentication mode="Forms">
<forms loginUrl="Login.aspx" name="Login" protection="All"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>

 

The problem is that it seems lots of folks don’t want users to automatically redirect to the Login.aspx page when they navigate to their site home page.

To require authentication for all the pages in your web application EXCEPT the home page (Default.aspx)) 

Also add a location section to your web.config file that explicitly allows anonymous users to access JUST the default.aspx page.

<location path="default.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>

You can use the web.config location element to specify folders as well as pages which makes it a very powerful construct.

 

Technorati Tags: Microsoft ASP.NET Security Tips & Tricks

Trapping Intentional Cross Site Scripting (XSS) Attempts in ASP.NET

So I’m building an ASP.NET application to host Podcasts and in the post submission logic I want folks to be able to submit markup, but not JavaScript.

image

ASP.NET automatically traps suspicious posts to the server, but the results have to unfortunate defines.

First is the ugly resulting page. We’ve all seen them.

image

And the second is that I may want to be able to add some SPECIFIC logic to handling that Security exception because it probably means someone is intentionally trying to hack my web site.

It turns out that this is another that ASP.NET makes easy to solve.

First, add a Global.asax file to your solution and code the global Application_Error event handler as follows.

   1:  protected void Application_Error(object sender, EventArgs e)
   2:  {
   3:      Exception objErr = Server.GetLastError().GetBaseException();
   4:      string err = objErr.Message.ToString();
   5:   
   6:      string secError = "A potentially dangerous Request.Form value was detected";
   7:      string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority +
                                          Request.ApplicationPath.TrimEnd('/') + '/';
   8:      Server.ClearError();
   9:   
  10:      if (err.IndexOf(secError) != -1)
  11:      {
  12:          Response.Redirect(baseUrl + "SecurityError.aspx");
  13:      }
  14:      else
  15:      {
  16:   
  17:          Response.Redirect(baseUrl + "Error.aspx");
  18:      }
  19:  }

When the specific form validation error is encountered we redirect to a specific web page. (SecurityError.aspx)

The user gets a much better experience.

image 

This solves the second problem with the default handling. Even without additional work on my part the IIS Server Logs will be able to tell me how many times this happens along with information about the requests that generate them.

If I want to get more specific I can forward the originals HTTP request and exception info to SecurityError.aspx and take some action.

If the form can only be submitted by a user who is logged in to my application, even better. I can count how many times then cause this eror to happen and then based on that data I can warn them, log them off or ban them from my site completely

Do you add security specific error handling to your site ? If so, let me know.

Technorati Tags: ASP.NET Security Tips & Tricks

I get many (MANY) email from customers who are struggle to answer specific technical problems. As time permits I’m going to start answering them here,

I recently received an email from a developer building an application using the Ajax Control Toolkit and he needed his page to contain an Accordion Control in which all Panes were CLOSED when the page was initially loaded.

Like this ……

image

The Accordion Control in the earliest versions of the Ajax Control Toolkit lacked this ability but now it’s pretty easy.

By default, the Accordion Control requires one of it’s contained Panes must be open at all times.

So, there are two things we need to do in our Accordion Control configuration.

  1. Configure the control so that it does NOT require at least one open Pane.
  2. Set the default Pane index to one that does not exist so that NO Pane will be open when the page loads.

Luckily, the Control exposes the properties that we need.

Here is the control syntax.

<ajaxToolkit:Accordion ID="MyAccordion" runat="server"                        

HeaderCssClass="accordionHeader" ContentCssClass="accordionContent" 

FadeTransitions="true" FramesPerSecond="40" TransitionDuration="250" 

AutoSize="None" RequireOpenedPane="false" SelectedIndex="-1">

 

The bottom two attributes are the ones that interest us.

RequireOpenPane=”false” – Tells the Accordion control that it’s OK for all the contained Panes to be closed. 

SelectedIndex=”-1” – Tells the Accordion control to set as Active the Panel whose index is –1 (which doesn’t exist”.

These two settings combine to offer the startup effect that you see in th epicture above.

[ Click HERE to download a sample project of this technique. ]

Technorati Tags: Microsoft ASP.NET AJAX Controls Accordion Tips & Tricks

Test your ASP.NET knowledge on an Android phone !

android_dda_lab_3

A free Android application for testing your ASP.NET Development Knowledge.

[ Check it out here. ]

Unwinding the page lifecycle events

Since I spent some time today working with control extenders and exactly where in the page lifecycle to do what, I thought I’d share the whole list.

If (!IsPostBack)

  1. Begin PreInit
  2. End PreInit
  3. Begin Init
  4. End Init
  5. Begin InitComplete
  6. End InitComplete
  7. Begin PreLoad
  8. End PreLoad
  9. Begin Load
  10. End Load
  11. Begin LoadComplete
  12. End LoadComplete
  13. Begin PreRender
  14. End PreRender
  15. Begin PreRenderComplete
  16. End PreRenderComplete
  17. Begin SaveState
  18. End SaveState
  19. Begin SaveStateComplete
  20. End SaveStateComplete
  21. Begin Render
  22. End Render

If(IsPostBack)

  1. Begin PreInit
  2. End PreInit
  3. Begin Init
  4. End Init
  5. Begin InitComplete
  6. End InitComplete
  7. Begin LoadState
  8. End LoadState
  9. Begin ProcessPostData
  10. End ProcessPostData
  11. Begin PreLoad
  12. End PreLoad
  13. Begin Load
  14. End Load
  15. Begin ProcessPostData (Again)
  16. End ProcessPostData (Again)
  17. Begin Raise ChangedEvents
  18. End Raise ChangedEvents
  19. Begin Raise PostBackEvent
  20. End Raise PostBackEvent
  21. Begin LoadComplete
  22. End LoadComplete
  23. Begin PreRender
  24. End PreRender
  25. Begin PreRenderComplete
  26. End PreRenderComplete
  27. Begin SaveState
  28. End SaveState
  29. Begin SaveStateComplete
  30. End SaveStateComplete
  31. Begin Render
  32. End Render

Implementing a jQuery Modal Window in ASP.NET

I’ve recently had several questions about attempts to use the Ajax Control Toolkit’s Modal Dialog, or more accurately, to misuse it, as a window.

It’s a “dialog” and therefore not well suited to being used for receiving data from the user.

Controls like the Modal Dialog Extender Control are convenient when they do when we want them to do but when they don’t there is no reason not to “roll our own” functionality.

In this case I’ve built a sample using jQuery to display a Semi-Modal Window to allow the user to edit a field on the page.

I say “semi” Modal because clicking outside the Window causes the edits to be aborted, the Window to be closed, and the page to be visually restored.

The page normally looks like this…….

jqModal

Then Clicking on the “Edit Photo Caption” link causes this to happen.

jqModal-EditMode

In this dialog one can edit the caption that appears below the photo.

The interesting thing here is that, though I’m using jQuery to display the Window, the rest is plain ASP.NET server controls and code behind.

The “Save” button is an ASP.NET button control which means that there is a Server-Side event handler where I can process they newly entered Photo Caption.

In the case of this demo I just update the page display but we could also use that Click event handler to persist the changed data to a database since it runs server side. (No “services” required.)

The Code…

I start with generating a default ASP.NET 4 Web Forms Application with Visual Studio 2010

Then we pull jQuery via a reference in the master page.

<script type="text/javascript"
     src="http://code.jquery.com/jquery-latest.pack.js"></script>

Note that the new Web Forms project template in Visual Studio 2010 includes versions of jQuery and even one that has IntelliSense support but I’ve opten to dynamically bull the latest version directly from the jQuery code repository.

Next, we have some styles added to the generated Style.css file to handle making the page opaque when we show the Window as well as styles for the Window itself.

   1: #mask

   2: {

   3:   position:absolute;

   4:   left:0;

   5:   top:0;

   6:   z-index:9000;

   7:   background-color:grey;

   8:   display:none;

   9: }

  10:

  11: #boxes .window {

  12:   position:absolute;

  13:   left:0;

  14:   top:0;

  15:   width:440px;

  16:   height:200px;

  17:   display:none;

  18:   z-index:9999;

  19:   padding:20px;

  20: }

  21: 

  22: #boxes #modalwindow {

  23:   width:375px;

  24:   height:203px;

  25:   padding:10px;

  26:   background-color:#ffffff;

  27: }

  28: 

  29: .stylecenter

  30: {

  31:     text-align: center;

  32: }

 Next we have the code for displaying the Window. Note that this jQuery code is bound ONLY to a DOM <A> Element named “modal”.

Lets look at the code and then I’ll call out a detail or two.

   1:      <script type="text/javascript">
   2:          $(document).ready(function () {
   3:   
   4:              // Set up for displaying modal dialogs
   5:              $('a[name=modal]').click(function (e)
   6:              {
   7:            // Prevent the default link behavior of navigation so we can
                    use the link to show the Window
   8:                  e.preventDefault();
   9:   
  10:                  // Determine which href was clicked if it was in fact an href
(though this demo as only one.) 
  11:                  var id = $(this).attr('href');
  12:   
  13:                  // Determine browser windows dimensions. 
  14:                  var maskHeight = $(document).height();
  15:                  var maskWidth = $(window).width();
  16:   
  17:                  // Set dimensions for the mask to opaque the screen when 
                        the modal window is displayed.
  18:                  $('#mask').css({ 'width': maskWidth, 'height': maskHeight });
  19:   
  20:                  // Make the Window Opaque        
  21:                  $('#mask').fadeIn("fast");
  22:                  $('#mask').fadeTo("slow", 0.8);
  23:   
  24:                  //Get the window height and width
  25:                  var winH = $(window).height();
  26:                  var winW = $(window).width();
  27:   
  28:                  // Set the Modal Window's dimensions to center in the 
                          browser window.
  29:                  $(id).css('top', winH / 2 - $(id).height() / 2);
  30:                  $(id).css('left', winW / 2 - $(id).width() / 2);
  31:   
  32:                  // Show the Modal Window
  33:                  $(id).fadeIn("fast");
  34:   
  35:              });
  36:   
  37:              // Handle Close Button Click Event
  38:              $('.window .close').click(function (e) {
  39:                  // Cancel the link behavior
  40:                  e.preventDefault();
  41:   
  42:                  $('#mask').hide();
  43:                  $('.window').hide();
  44:              });
  45:   
  46:              // The user clicks OUTSIDE the Modal Window and the window will be 
                      closed without save.
  47:              $('#mask').click(function () {
  48:                  $(this).hide();
  49:                  $('.window').hide();
  50:              });
  51:   
  52:          });
  53:  </script>

We should also note the HTML for the like and the Window to be shown when that like is clicked.

<a href="#modalwindow" name="modal">Edit Photo Caption</a>
</div>
<div id="boxes">
<div id="modalwindow" class="window">
<center>Enter New Caption</center><br />
<asp:TextBox ID="ClientDataTextBox" runat="server" ClientIDMode="Static"
    TextMode="MultiLine" Height="120" Width="370"></asp:TextBox><br />
<asp:Button ID="ModalButton" runat="server" Text="Save" onclick="ModalButton_Click" />
</div>
<!-- Mask to cover the whole screen -->
<div id="mask"></div>
</div>

 Note the line …..

$('a[name=modal]').click(function (e)

“modal” is the name of the <A> object that for opening the Window.

 
Note that the href= is set to the same name as the id of the <DIV> to be displayed when the <A> is clicked and it is that relationship that causes the related Window to be displayed.
 
The cool thing about this is (to me anyway) how I can intermingle ASP.NET and jQuery JavaScript. The fields in the Modal Window get processed in my Code-Behind so I don’t need to write extra JavaScript to fetch and handle the new Photo Caption and I don’t need to write Ajax service Methods to handle Server Side processing of that new data,
 
For me it is this sort of change in style that is indicative of the “new” ASP.NET Web Forms developer.
 
You can grad a zip file of the ASP.NET 4 project [ HERE ]
 
Have Fun !
 
PS: I adapted code from this post http://www.queness.com/post/77/simple-jquery-modal-window-tutorial  to ASP.NET and Failed to give attribution to the original author.  My apologies to Queness.
 
Technorati Tags: ASP.NET 4 jQuery Modal Window Code

Building an Awesome Community Web Site

Some time ago I started playing with the idea of organizing an Open Source project to build a CMS.

It generated a lot of interest, but the “expectations” seemed overwhelming to me. NETOOP is not dead, I still plan to build it but I intend to build version one myself (On MVC) and release it as FREE source.

In the mean time, I’m planning what content to build for 2010 and have decided to do a collection of projects based on building a great community site.

I’m going to write the code and record videos detailing the implementation or the parts.

I hope YOU will suggest and discuss features with me here on my blog! I will release the code as FREE/MSPL at different milestones.

The “design” that I’m starting with is live at www.MMARingside.org

MMSRS_001

It’s currently deployed on .NET 3.5 on Web Forms.

  • I’ll be updating to ASP.NET 4 very soon.
  • I will be doing a MVC version.
  • As much code as possible will be modular and transportable.

The first features I’ll be working on are…….

  • Add ASP.NET Membership System
  • Add Roles
  • Add CUSTOM Profile System
  • Add Daily Notice Admin Editor (Admin Only, Rich Text Editor)

Please share your thoughts and feature ideas and don’t worry if MMA is not your thing.

I just chose a sports application so we could have fun with rich media features !!!!!

 

Technorati Tags: Microsoft ASP.NET CMS MMA UFC How-Do-I

BOOK – ASP.NET 4.0 by Joydip Kanjilal

0071604103

ASP.NET 4 is almost here and the new stuff is great but it’s hard to make the time to stay current and keep up to date on all the new stuff.

Joydip has done the heavy lifting for us and encapsulated core concepts in his new book ASP.NET 4.0 Programming.

As you can read in my comment on the inside cover, this book is more than a quick feature tour of the new stuff. It’s a concise guide to building ASP.NET 4 application using the new “paradigm.”

Read it as a primer to the technologies that you;ll see at this years MIX and TechEd and my upcoming ASP.NET 4 video series.

[ Get it HERE ]

Technorati Tags: Book ASP.NET 4

30 “Quick Hit” Videos for folks that couldn’t join us at PDC

Hi folks! I’m posting this from the PDC09 keynote where I’m listening to Don Box show off Azure !

For web developers, I prepared 30 “Quick Hit” videos on stuff that’s new in the latest wave for ASP.NET Develoeprs.

It’s far from a complete list, and they are not meant to be real tutorials (They are NOT How-Do-I videos).

Think of them as “feature previews” with more learning based material coming in the near fututr.

Here is a partial list.

Have fun

www.asp.net/learn

ASP.NET 4

ASP.NET 4 "Quick Hit" – New Rendering Option for Check Box Lists and Radio Button Lists

ASP.NET 4 "Quick Hit" – Persistent GridView Row Selection

ASP.NET 4 "Quick Hit" – Table Free Templated Controls

ASP.NET 4 "Quick Hit" – Easy State Compression

ASP.NET 4 "Quick Hit" – Tableless Menu Control

ASP.NET 4 "Quick Hit" – Imperative JavaScript Syntax for Microsoft Client Side Controls

ASP.NET 4 "Quick Hit" – The ScriptLoader

ASP.NET 4 "Quick Hit" – jQuery Syntax for Microsoft Ajax

ASP.NET 4 "Quick Hit" – AJAX Data Templates

ASP.NET 4 "Quick Hit" – Hidden Field Divs

ASP.NET 4 "Quick Hit" – Disabled Control Styling

ASP.NET 4 "Quick Hit" – Declarative WebForms Routing

ASP.NET 4 "Quick Hit" – Outbound WebForms Routing

ASP.NET 4 "Quick Hit" – Auto Start

ASP.NET 4 "Quick Hit" – Clean Web.Config Files

ASP.NET 4 "Quick Hit" – Predictable Client IDs

ASP.NET 4 "Quick Hit" – Selective View State

ASP.NET 4 "Quick Hit" – The HtmlEncoder Utility Method

 

VS2010

Visual Studio 2010 "Quick Hit" – Code Search View Hierarchy

Visual Studio 2010 "Quick Hit" – IntelliSense Smart Lists

Visual Studio 2010 "Quick Hit" – Multi-Monitor Support

Visual Studio 2010 "Quick Hit" – New Web Project Template

Visual Studio 2010 "Quick Hit" – New Multi-Targeting

Visual Studio 2010 "Quick Hit" – Websites Instead of Web Projects

Visual Studio 2010 "Quick Hit" – Snippets IntelliSense

Free ASP.NET 4 and VS 2010 Beta Hosting to help you get up to FOUR !

MaximumASP

MaximumASP is offering a free hosting account so you can get started with ASP.NET 4 and Visual Studio 2010.

On this account you can test ASP.NET 4 applications in a hosting environment and try out the new publishing features with Visual Studio 2010 and the Microsoft Web Deployment Tool.

  • Windows Server 2008 R2 / IIS 7.5
  • .NET Framework 4 Beta 2
  • 1GB disk space
  • 50 MB SQL Server 2008 database
  • MS Deploy Access
  • FTP over SSL Access

The environment on which your apps will be running is a slimmed down version of our robust MaxESP platform. Experience some of the platform’s features such as instant scaling, application aware load-balancing, and the IIS Remote Manager. If you like what you see during the ASP.NET 4 beta, sign up for a full account. We would love to have you.

http://aspnet4beta.maximumasp.com/

 

Technorati Tags: Microsoft ASP.NET Beta Hosting

ASP.NET 4 / VS 2010 “Quick Hit” Videos

Now that the “Dev 2010” wave of products is in beta and we’re getting closer5 and closer to release, I‘ve started publishing “Quick Hit” videos on the new features.

These are not really tutorials (Not like the How-Do-I videos) but rather just “quick” peeks to show you the new stuff.

I’ll start working on more detailed training  after PDC.

The first 5 videos are now live:

http://www.asp.net/learn/aspnet-4-quick-hit-videos/

http://www.asp.net/learn/vs2010-quick-hit-videos/

 

Technorati Tags: Microsoft ASP.NET Visual Studio

eBook 51 Tips, Tricks and Recipes with jQuery and ASP.NET Controls

51jQueryTips

 I found this cool eBook and wanted to share it with you all since jQuery is. more and more, become a common part of the ASP.NET Development experience.

The book includes…

· 51 Tips, Tricks and Recipes with jQuery and ASP.NET Controls eBook (PDF)

· Entire Source Code of the eBook

· Cross Browser Scripts – tested on IE 7, IE 8, Firefox 3, Chrome 2, Safari 4

· Common code that runs on ASP.NET Pages, Master Pages, and in most cases, HTML pages too.

You can read the table of contents [ HERE ]

YOU can buy the ebook [ HERE ]

ASP.NET 4 Beta 2 – New Version, New Docs, New MSDN Site !

We’ve been BUSY !

ASP.NET 4.0 and Visual Studio 2010 Beta 2 was released to MSDN Subscribers earlier this week.

General availability is scheduled for tomorrow !

Read the announcement [ HERE ] with an overview about the new SKUs and features or go straight to the download [ HERE ].

Check out the new look !!!!

image_thumb_7407CD79

You’ll find the documentation at the MSN web site [ HERE ] and when you do, you’ll see that the Server & Tools On Line team has been busy improving the MSDN site experience.

WebDevDocs

 

There is a TON of new stuff and I’ve built a list of potential topics for new content that I’m building. I though it might be useful if I shared that list here so …..

DIG IN !!!

Core Services   

    Web.config File Minification   
    Extensible Output Caching   
    Auto-Start Web Applications   
    Permanently Redirecting a Page   
    The Incredible Shrinking Session State   
    Expanding the Range of Allowable URLs   
    Extensible Request Validation
    Object Caching and Object Caching Extensibility
    Extensible HTML, URL, and HTTP Header Encoding   
    Performance Monitoring for Individual Applications in a Single Worker Process   
    Multi-Targeting  

 
New Features in ASP.NET AJAX 4  

 
    Client Template Rendering   
    Instantiating Behaviors and Controls Declaratively   
    Live Data Binding   
    Using the Observer Pattern with JavaScript Objects and Arrays   
    The DataView Control   
    The AdoNetServiceProxy Class   
    The DataContext and AdoNetDataContext Classes   
    Refactoring the Microsoft AJAX Framework Libraries   
    The DOM Ready Event   
    Using JSONP to Retrieve Cross-Domain Data

  
Web Forms  

 
    Setting Meta Tags with the Page.MetaKeywords and Page.MetaDescription Properties   
    Enabling View State for Individual Controls   
    Changes to Browser Capabilities   
    Routing in ASP.NET 4   
    Setting Client IDs   
    Persisting Row Selection in Data Controls   
    ASP.NET Chart Control   
    Filtering Data with the QueryExtender Control   
    Html Encoded Code Expressions   
    Project Template Changes   
    CSS Improvements   
    Hiding div Elements Around Hidden Fields   
    Rendering an Outer Table for Templated Controls   
    ListView Control Enhancements   
    CheckBoxList and RadioButtonList Control Enhancements   
    Menu Control Improvements   
    Wizard and CreateUserWizard Controls   

ASP.NET MVC
    Areas Support

    Data-Annotation Attribute Validation Support
    Templated Helpers

Dynamic Data

    Enabling Dynamic Data for Existing Projects   
    Declarative DynamicDataManager Control Syntax   
    Entity Templates   
    New Field Templates for URLs and E-mail Addresses   
    Creating Links with the DynamicHyperLink Control   
    Support for Inheritance in the Data Model   
    Support for Many-to-Many Relationships (Entity Framework Only)   
    New Attributes to Control Display and Support Enumerations   
    Enhanced Support for Filters   

Visual Studio 2010 Web Designer Improvements   

    Improved CSS Compatibility   
    HTML and JScript Snippets   
    JScript IntelliSense Enhancements   
    Web Application Deployment with Visual Studio 2010   
    Web Packaging   
    Web.config Transformation   
    Database Deployment   
    One-Click Publish for Web Applications   

Technorati Tags: Microsoft MSDN ASP.NET Beta VIsual Studio 2010

2 New Videos Published on www.ASP.net

video-8605

The first shows how ASP.NET helps you understand and easily defend against Cross Site Scripting (XSS) in your Web Applications. This one has a REAL WORLD example of DOM Injection based hijacking attacks.

Note that Script Injection is the OWASP #1 vulnerability.

video-8606

The second video, is a light introduction to programming with LINQ and compares simple data access between ADO.NET and LINQ from a developer experience perspective.

Next I’ll be playing with SQL Injection – the OWASP #2 vulnerability.

Technorati Tags: Microsoft ASP.NET Video Security XSS LINQ Data

Write ASP.NET without Web Forms or MVC !

Some time ago I tweeted [ Follow Me ] that you could write ASP.NET applications without using Web Forms or ASP.NET MVC

Frameworks are a convenience !  Web Forms, MVC, Cake, Symphony, etc.

So what if you want to use the power of the .NET framework, but want complete control over the client code and don’t want to be forced to use the MVC pattern.

No Problem – ASP.NET and Web Forms are not synonymous !!

Look at these 2 “Hello World” applications.

PHP Hello World

   1: <html xmlns="http://www.w3.org/1999/xhtml">

   2: <head>

   3:     <title></title>

   4: </head>

   5: <body>

   6:   <?php

   7:     echo ("This is a test !");

   8:   ?> 

   9: </body>

  10: </html>

ASP.NET Hello World.

   1: <%@ Page Language="C#" %>

   2: <html xmlns="http://www.w3.org/1999/xhtml">

   3: <head runat="server">

   4:     <title></title>

   5: </head>

   6: <body>

   7:     <% Response.Write("This is a test !"); %>

   8: </body>

   9: </html>

On the ASP.NET side, I could include YUI or jQuery and still use ASP.NET controls if I wanted or not use any server side controls and even turn off view-state.

If you don’t have call response.write you can even use the short hand …

<%= "This is a test !" %>

I can still code to the page lifecycle events if I want, or, code for top-to-bottom execution as seen above !

Form and Query String Variables are all accessible via the request object (and tons of other stuff)

Give it a try !

Did you know there is an ASP.NET Channel on IRC ?

user-hydra-medium-1

Are you an IRC user ? It a real-time chat with dozens of your friends.

About 2 years ago an ASP.NET developer started an ASP.NET chat channel on the FreeNode IRC network. 

There are currently between 60 and 70 people in the channel on a given day and still growing.

You can use this link to visit:  https://webchat.freenode.net/?channels=%23%23asp.net.

But you will probably want a real IRC client.

I’m currently using HydraIRC which you can find [ HERE ]

If you stop by, say hi to me at “MisfitGeek”.

Technorati Tags: Microsoft ASP.NET IRC
  Some time ago I posted about JavaScript being inevitableOver the last couple of weeks I’m been writing some web security related videos and writing some DOM based hacking examples.

In the course of that I picked up Murach’s JavaScript and DOM Scripting training and reference. It’s everything I’ve come to expect from a Murach’s book !!! 

It’s simply a complete guide to writing JavaScript with a practical guide to not only “doing” JavaScript but manipulating the DOM and CSS.

It’s great to read a book that continues to have value after you’ve read it cover to cover.

I now have a stack of Murach’s books on my desk :) and this one is proving to be very useful, not only for the security stuff I’m doing but as I’m diving deeper into ASP.NET MVC and writing more client side code.

Hope you can check it out.

RELEASED – ASP.NET MVC 2 Preview 2

ASP.NET MVC 2 is coming along nicely and there is a new preview for your learning pleasure.

It will work side-by-side with ASP.NET MVC 1, and will be included in the .NET 4 Beta 2 release.

Some new stuff …….

  • ModelMetadata and ModelMetadataProvider Classes

    The ViewDataDictionary class exposes a ModelMetada object that contains the metadata that is extracted from the model by the ModelMetadataProvider class. This allows the templated helpers to consume this metadata and adjust their output accordingly. You can use the default provider or create custom ones.  

Model Validator Providers

The model validation providers class provides an abstraction for obtaining validation logic for the model. You can use the default provider or create custom ones.

Client-Side Validation

The model validator provider class exposes validation metadata to the browser in the form of JSON-serialized metadata that can be consumed by a client-side validation library. The provider class allows you to use other client validation frameworks by writing an adapter that processes the JSON metadata and calls into the alternate client validation library. The preview release includes the jQuery validation library and a client-side validation adapter for that library.

New Code Snippets for Visual Studio 2010

Set of HTML code snippets for MVC 2 for VS 2010 Beta 2.

 New RequireHttpsAttribute Action Filter

ASP.NET MVC 2 Preview 2 includes a new RequireHttpsAttribute class that can be applied to action methods and controllers. By default, the filter redirects non-SSL (HTTP) requests to the SSL-enabled (HTTPS) equivalent.

 Overriding the HTTP Method Verb

When you build a Web site by using the REST architectural style, HTTP verbs (GET, PUT, POST and DELETE) are used to determine which action to perform for a resource. ASP.NET MVC includes attributes that you can apply to action methods and that enable ASP.NET MVC to select an action method based on the HTTP verb.

Details Page: http://go.microsoft.com/fwlink/?LinkID=154414

Readme doc: http://go.microsoft.com/fwlink/?LinkID=157066

Installer: http://go.microsoft.com/fwlink/?LinkID=154413

Technorati Tags: Microsoft ASP.NET MVC

NEW VERSION – Ajax Control Toolkit

Download [ HERE ] and see Demos [ HERE ]

In addition to Bug fixes (courtesy of Obout) for some of the top-voted issues, we have two new controls !

First, new controls!

  1. Seadragon, the JavaScript-only way to do Deep Zoom.
  2. Asynchronous AJAX File Upload Control (upload files without a full postback with no plug-in)

The Upload control is especially cool as it has client and server-side events that get triggered when the file has been uploaded.

On the server-side, you have access to the uploaded file’s byte stream, which you can save to disk (or database, or whatever).

Great to see our Ajax stack continue to evolve.

Technorati Tags: Microsoft ASP.NET AJAX Controls

Microsoft Web Application Toolkits

clip_image003

Web Application Toolkits are designed to enable Web Developers to simply extend their web application capabilities by providing them with a packaged set of running samples, templates and documentation.

The goal for the Web Application Toolkits is to provide Web Developers with resources such as project templates, controls, and code samples along with simplified documentation all in a consistent packaged format that is easy to download and run in a very short period of time. One of the key criteria around the Web Application Toolkits is to enable Web Developers to get to an F5 (Run) experience very quickly to ensure that this is the right solution for their problem; How many times have you heard developers trying for hours to get a sample to work only to find it does not do what they expected. The expectation is that with the correct prerequisites installed using the Web Platform Installer, a Web Developer can have a Web Application Toolkit sample application installed and running in 5mins.

clip_image005 Web Application Toolkit for Internet Explorer 8 Extensibility

Today users can access rich information and services while they are browsing a site; it’s not a trivial task to expose this content to the same users when they are not on that site. The goal of this Web Application Toolkit is to leverage the new features in Internet Explorer 8 (Web Slices, Accelerators and Visual Search Providers) to extend the reach of your web site and services also to those users that are not on your site. The Web Application Toolkit includes a set of ASP.NET Web Controls that you can use to take advantage of these IE new features in your own Web application.

Check out the accompanying screencast.

clip_image007 Web Application Toolkit for Bing Search

Bing is a powerful new Decision Engine designed to help consumers accomplish tasks and make faster, more informed decisions. The Bing Application Programming Interface (API) provides developers programmatic access to Bing, offering flexible options for building or enhancing your site or applications. This Web Application Toolkit shows how to take advantage of the Bing API to add search capabilities to your Web site by leveraging the various search results that the Bing API provides, including Web content, images, news and videos, among others. Through this Web Application Toolkit you will also discover how to use ASP.NET AJAX and jQuery to provide an enhanced and more interactive end user experience when using the Bing API.

clip_image009 Web Application Toolkit for REST Services

Many Web applications today are starting to expose data as REST service interfaces, so it can be accessed through APIs by other tiers of the application or even by other applications. A RESTful web service is a simple Web service implemented using HTTP and the principles of REST. REST Services focus on resources; each one is represented by a unique URI, and users interact with them via their URI using the HTTP uniform interface. This Web Application Toolkit shows how to easily add REST service interfaces for an existing Web application. The Web Application Toolkit includes a sample REST service, two sample client applications that access the REST services, one using simple ASP.NET Web Forms and a second Web application using AJAX to asynchronously invoke the REST service and finally a custom project template for Visual Studio to make it very easy to build new REST Services.

Check out the accompanying screencast.

clip_image010 Web Application Toolkit for Mobile Web Applications

This Web Application Toolkit is designed to demonstrate how to extend an existing ASP.NET MVC Web application to provide access from mobile devices. To enable mobile access, the Web application should have views targeting each of the mobile devices to be supported. The MVC pattern helps you create applications that separate the different aspects of the application (input logic, business logic, and UI logic), while providing a loose coupling between these elements.  This Web Application Toolkit provides a component called MobileCapableViewEngine that enables the Web application to show the appropriate view depending on the device’s browser that is performing the request.   It also includes a sample site that provides different views for Windows Mobile, IPhone, and Blackberry devices.  

Check out the accompanying screencast.

clip_image012 Web Application Toolkit for Template-Driven Email

This Web Application Toolkit is designed to demonstrate how to generate and send dynamic, template-based emails from a web application. There are many common scenarios where notification emails need to be sent to end users. Examples of these common scenarios may involve notifying a user of their newly created account, sending a new password in respond to a forgotten password request, or emailing an alert under specific business circumstances, such as the creation of a order. Typically the E-mails sent from a Web application scenario are formatted as HTML, include CSS stylesheets, and images and need to be generated dynamically with custom or user-specific data.  This Web Application Toolkit includes samples that show how to use templates to generate these dynamic email bodies. 

Check out the accompanying screencast.

clip_image014 Web Application Toolkit for making Your Web Site Social

Adding social capabilities to your Web site allows you to attract new users, keep them on your Web site for longer and get them to come back more often. This Web Application Toolkit shows how, using a few lines of code with the Windows Live Messenger Web Toolkit, it is possible to add social capabilities to a Web site with instant messaging from a website to various client endpoints like Windows, Windows Mobile, Xbox 360 and Mac.  Behind the scenes is a powerful set of UI Controls and a JavaScript library that connect your website to the Messenger Service which is used by 330 million users around the world. 

Check out the accompanying screencast.

clip_image016 Web Application Toolkit for FAQs

The majority of web sites have the need to display a list of frequently asked questions to their users. Although it’s not difficult to create a simple set of FAQ pages, creating a great user experience that supports searching for FAQs, filtering, and paging, can become more difficult. Furthermore, this is often common functionality that has to be implemented repeatedly in multiple Web sites. This Web Application Toolkit is designed to provide a starting set of code including ASP.NET pages, data access logic, and database schemas, for integrating Frequently Asked Questions into your own ASP.NET MVC Web application.

Check out the accompanying screencast.

You can find the complete list of Web Application Toolkits here.

Web Deployment Tool has gone RTW

After 2 years of development and lots of customer feedback, Microsoft is proud to announce that the Web Deployment Tool has gone  RTW version 1.0!

You can now download the RTW version and use it in production, and it is fully supported by Microsoft Support.

Install our 1.0 RTW release from http://www.iis.net/webdeploymenttool, available in x86 and x64.

Version 1.0, includes the following components:

  • Powerful APIs that allow you to deploy, sync and migrate web applications on IIS, and perform granular operations like changing IP bindings, site names and changing file structures on the fly. You can also create a new provider to sync a new type of resource.
  • Command-line tool (msdeploy.exe) that allows you to perform all the same operations available in the APIs.
  • User interface built into IIS Manager 7.0 on Vista, Windows 2008 and Windows 7 that allows you to create packages (zip files containing IIS config, content, databases and more) and install them.
  • Delegation framework and service built into IIS 7.0 that allows you to delegate tasks like installing applications and databases without requiring them to be administrators on the box.
  • Remote administrative service that works on IIS 6.0 and 7.0 to allow server-level synchronization by administrators.

So, what can you do with these components?

  • Migrate Web applications from IIS 6.0. Simplify the planning of your IIS 6.0 to IIS 7.0 migrations by determining incompatibilities and previewing the proposed changes before starting the process. Learning about any potential issues in advance gives you the chance to take corrective measures and simplifies migration.
  • Synchronize your server farm. Synchronize between IIS 6.0 > IIS 6.0 or IIS 7.0, and only sync the differences. The tool simplifies the synchronization process by automatically determining the configuration, content and certificates to be synchronized for a Web site. Optionally, specify additional resources for sync, including databases, COM objects, GAC assemblies and registry settings.
  • Package, archive and deploy Web applications. Package configuration and content of Web applications, including databases, and then use the packages for storage or redeployment. These packages can be deployed using IIS Manager without requiring administrative privileges. The tool integrates with Visual Studio 2010 to help developers streamline the deployment of Web applications to the Web server. The tool also integrates with the Web Platform Installer to allow you to simply and easily install community web applications.

Some of our favorite customer scenarios include:

  • Create application packages that contain all of the IIS config, content, databases and more, including parameters so that when the server admin installs the package, they are prompted to fill in parameters like SQL Server connection string.
  • Build an automated deployment system using our APIs, cmd-line or the Visual Studio integration, so that you can deploy daily from test to staging to production.
  • Allow your developers to directly deploy to the staging server without admin intervention, and lock down exactly what they can change (mark a folder as an app but not change the site’s binding).
  • Replace Application Center with a set of scripts or programs that call our APIs or cmd-line to sync multiple servers in a web farm.
  • Build a roll-back solution by taking a package of your live app, deploying the app_v2 package created in your dev environment, and checking for failures. In case of failures, automatically apply the v1 package or backup that you took.

 

Technorati Tags: Microsoft IIS Deployment

It’s called WebSpark ! (http://www.microsoft.com/web/websitespark/)

Here is the OFFICIAL Description.

WebsiteSpark is a new global program, designed by Microsoft to help small professional Web development and design service companies succeed, by providing new business opportunities through connections with global partners and customers, support and training, and software tools – at no upfront cost. WebsiteSpark provides professional Web development and design companies with an innovative vehicle to get access to:

 Business Opportunities: Opportunities to expand their customer base and drive new business, by showcasing their capabilities and connecting with partners via the WebsiteSpark Marketplace and other Microsoft marketing and business networking vehicles.

 Support and training: Professional support from Microsoft and connections with WebsiteSpark Network Partners, Hosting Partners, and other Web developers and designers with complementary technologies or business models—an entire ecosystem that can provide a wide range of technical and business resources for every Web professional need.

 Software and solutions: Fast, easy, and immediate access to current full-featured Microsoft development tools and Web server production licenses at no upfront cost, to build, design and bring to market differentiated, innovative, and rich Internet sites.

Read ScottGu’s blog post about the program [ HERE ]

Advertising on the ASP.NET Web Site ?

BuyMyStuff

We’re spending a LOT of time planning a complete re-vamping of the  www.ASP.NET web site.

Recently I came across this comment in a blog entry discussing what Microsoft should do to improve the web site.

The justification that the ads exist to offset the cost of running the site is indefensible for a company Microsoft’s size.

Though most folks don’t care about the ads and many folks tell us they even find them useful, this is not the first time I’ve hear this.

The last time I made a comment about the cost of running our little collection of web properties a “community member” with a healthy sense of entitlement basically called me a liar and demanded to see our accounting :)

Some times folks don’t want to hear it, or don’t “get it” but Microsoft is a company like any other.

A few notes as it pertains to operational funding at Microsoft.

  • Microsoft is not permitted by the government to print it’s own money. The company’s operating expenses are acquired by way of SALES, just like any other commercial entity.
  • If, after all is said and done, if there is any money “left over” from the difference between the COST of developing and supporting our products and the revenue from sales – it goes to the people who OWN Microsoft – OUR SHAREHOLDERS.
  • There is no “Vault” at Microsoft where teams go with their shopping cart to get the money they need to do what they need to do.

So as to avoid the nastiness I experienced that last time i discussed how much it costs to run the .NET sites, lets just agree it is a non-trivial amount of money.

Apart from “pure operational costs”, where do all the articles, videos, whitepapers, code, design, new features, etc come from ?  One way or the other, they all cost money. Some we pay for outright, some are paid for by way of the salaries of the Microsoft staff who have commitments to deliver those materials.

To me this seems like basic math (though maybe I’m missing some magic formula).

  • Everything costs money.
  • Each dollar can only be spent ONCE.

So given the costs of delivering the .NET community web sites and all the content they contain we can …..

  • Find ways to supplement our Microsoft budget in order to deliver MORE to our web site users.
  • Don’t supplement our operating budget (with things like ads) and do whatever we can with the budget we have. (Which clearly means less content for our developers.)

I’ve always assumed that our developers would prefer that we run ads in order to be able to afford to deliver more Videos, Samples, Articles, Whitepapers, Code, Features, etc.

Maybe I’ve been wrong about this.

Understand that we ONLY accept ads for things that are of interest to DEVELOPERS.

Given our traffic, we could make TONS of money if we sold ads for Cars, Hair Replacement, Viagra, etc. but we don’t. We only run ads for software development related products and services.

So, what would you suggest ?

  1. Keep the current model of Developer only ads discreetly displayed?
  2. Remove all ads and publish less content?
  3. Broaden the advertising policy to advertise “anything” and generate more content?
  4. Do something else (and you email me what to do and HOW to pay for it :) )

Thanks !

Expression SuperPreview – No VPCs required !!!

IE 6 doesn’t live happily side by side with IE 7 or IE 8

To do compatibility testing of a web page I usually have to fire up a VPC and access the page from a browser instance inside that VPC (one VPC for IE6, another one for IE7, etc.)

Lately I’ve started using “SuperPreview”.

It plugs in to Expression Web and lets you choose what browser to preview your page in (IE 6/7/8, Firefox)

Very cool !

ASP.NET AJAX 4.0 Preview 5 released to CodePlex

There is some COOL stuff coming …….

  • Client templates that can be used to format database data in the browser
  • Client controls such as the DataView control
  • Client DataContext component that supports change tracking and identity management
  • ADO.NET Data Services support
  • WCF and ASMX Web service support
  • JSONP support
  • Observable pattern for plain JavaScript objects
  • Live Bindings
  • Command Bubbling
  • Support for managing complex links and associations between entities from multiple entity sets or table
  • Dynamic and recursive templates
  • Binding Converters
  • Compatibility with the ASP.NET UpdatePanel

In the weeks to come I’ll be doing a collection of videos to the new features in ASP.NET / AJAX 4.0

In the mean time …….

[ Click HERE to go to the CodePlex release page. ]

 

Technorati Tags: Microsoft ASP.NET AJAX

Microsoft Dev-Labs Introduces Doloto for AJAX

Doloto

In their own words ….

Doloto is an AJAX application optimization tool, especially useful for large and complex Web 2.0 applications that contain a lot of code, such as Bing Maps, Hotmail, etc. Doloto analyzes AJAX application workloads and automatically performs code splitting of existing large Web 2.0 applications. After being processed by Doloto, an application will initially transfer only the portion of code necessary for application initialization.

Check it out (and GET it) [ HERE ]

Technorati Tags: Microsoft ASP.NET AJAX Doloto

GraffitiCMS troubles, Microsoft SQL Server and my blog future.

Winston Churchill said – “Democracy is the worst form of government except for all those others that have been tried.”

This sums up by blog experience with GraffitiCMS.

As many of you have emailed me, my blog has been having problems for about a month.

The default install of GraffititCMS has just crumbled over the increased traffic. It does down and my server needs to be rebooted (restarting IIS doesn’t always fix the issues.)

Files get locked and my server needs to be rebooted.

The stats tables get screwed up and my server needs to be rebooted.

I try to do comments admin and my server needs to be rebooted.

I’ve used DasBlog and BlogEngine.net and they are both super, but the versions I used did not support a true "database” which I desire. (BEN Now Supports a database provider model)

I used .Text but quit when Telligent pulled it into Community Server. .Text forked to become Subtext, which is super, but I couldn’t find themes I liked. Also, I worried a little about the future of Subtext since Phil is SOOOO busy at Microsoft. (He seems to be keeping up !)

I might have used Community Server but Rob Howard (Telligent) advised me against it as the next version really won’t be “single user friendly”.

I prototypes a migration from GraffitiCMS to WordPress. It sort of worked, GraffitiCMS seesm to have allowed some crap to slip though in my comments so I’d have to write a bunch of filtering to get it to really work, plus, I really want my blog to be extensible in ASP.NET and MySQL PHP driver performance on Windows is not good (WordPress does not support other databases out of the box.)

So, I found Al’s post here and  I migrated my Database for GraffitiCMS from VistaDB to SQL Server (Express).

Speed for complex tasks like comments admin has more then doubled and some of the things that were just plain broken seem fixed.

PLEASE email me if you see any anomalies etc. with my blog.

ASP.NET MVC – Is WebForms the VisiCalc of Web Development?

If you’re an “old geek” like me, you remember a number of software products that “changed the world”.

VisiCalc was THE spreadsheet of the day !  It might have done 2% of what Excel 2010 does, but when it was released it was an AMAZING innovation.

And how about DBase II (first released for CP/M) ?

It wasn’t the first database in the world, nor was it the first programming language, but it was an amazing innovation for the developer of the day that has evolved into forms that the original dBase creators probably never envisioned !

And then there was Turbo Pascal !!!!

When I got my first copy of Turbo Pascal it was pure genius. I think I paid $80 for it for my Televideo 802 CP/M machine. Up until then I was coding in assembly. The “C” compiler at the time was about $1,900 and the ADA compiler was like 5 GRAND !

The Turbo Pascal IDE (Editor) Debugger, Libraries etc. were state of the art back in the day, the best the world had ever seen. But it bore little resemblance to the Delphi products available today.

So what does this have to do with ASP.NET and WebForms?

Well, the point is, developer needs evolve. Perhaps faster than any other profession.

When ASP.NET was first designed, the majority of business application created were not web applications and the world was full of “Client / Server” developers.

We did Visual Basic, PowerBuilder, and Delphi. We built workgroup applications in Microsoft Access, FoxPro, dBase, Paradox, Notes, Excel, etc.

All these approaches to software development use the same “paradigm”. Forms, Events, and code that manipulates them.

Enter the World Wide Web.

My first web applications were CGI applications written in “C” and running on “Heavy Metal Unix”. 

My code had to do EVERYTHING – MY CODE needed to handle all the HTTP gook as well as generate the HTML to be returned to the client.

Later, when JavaScript came along, that same “C” code had to generate and embed JavaScript.

Now, we got it done, but 90% of our time was spent on plumbing.

Worse yet, doing this kind of web development required pretty detailed understanding of HTTP, HTML, Cookies, JavaScript, etc.

This took time to learn, and time to write – a lot of time. Meanwhile the world wide web EXPLODED in popularity.

All the technology players scrambled to meet the needs of developers who were moving to the web and needed to do it in a hurry.

Microsoft did a short lived effort IDC/HTX and then Classic ASP, Netscape did Live Wire.

Classic ASP was super and enjoyed great popularity, but only because it was less bad than all the other options :)

Enter ASP.NET and Web Forms.

ASP.NET/Web Forms was a perfect match for the skill set of the day (2001/2002) and was exactly what the industry needed at the time.

It delivered a developer “paradigm” that was very closely aligned with what developers were using. (VB, Delphi, PowerBuilder, Access, FoxPro, dBase, etc.)

– Forms, Events, Handlers, Libraries.

No need to know anything about HTTP, HTML, DHTML, JavaScript, etc.)

All the tough plumbing stuff was accessible in a huge base of well factored libraries, handled by the runtime, or done for you by Visual Studio.

It was perfect, and it’s acceptance was meteoric !

Then about 8 years later, Microsoft started showing ASP.NET MVC.

The “uber-geeks” and ALT.NETers were all over it and condemned Web Forms to a quick demise.

Some even suggested that Microsoft was conceding than WebForms was a mistake.

NOT !!!!!!

Web Forms was EXACTLY what we needed at the time, and it was massively successful in helping companies around the world take thousands of applications to the Web.

And then the Web, along with it’s users, matured, and they did it in “internet time” where a year is three months long. That’s a lot of evolution.

Today, more and more applications NEED access to the HTTP stack, they NEED to contain features and behaviors that can only be implemented in custom JavaScript (or Silverlight or Flash)

Like all development scenarios, developers get started doing meaningful work with the tools at hand and then inevitably start to “get under the covers”.

ASP.NET MVC does NOT hide you from the plumbing of the web. It doesn’t, for example, add state to HTTP’s innately stateless nature. To the contrary, in embraces it.

From my perspective, this makes product development from ASP.NET Web Forms to ASP.NET MVC a natural platform progression.

The ASP.NET Team is continuing to evolve Web Forms because many, many developers will continue  building great applications using Web Forms, and may never crack open MVC. There are new features in Web Forms 4.0 and there will be in 5.0 as well.

The ASP.NET team is also continuing it’s work on ASP.NET MVC. This is not to the EXCLUSION of Web Forms, but is an answer to the natural evolutionary needs of web developers.

Some developers will love the ASP.NET MVC way, other hate how much of the detail they need to code themselves when ASP.NET Web Forms just “gives it to them”.

And…. Some folks love working in the classic GOF MVC pattern. Others don’t like feeling “constrained” by a specific implementation structure.

I spent last week on campus (Microsoft headquarters where the ASP.NET is built!)  and spent much of my time meeting about the products and features the ASP.NET team will be delivering AFTER ASP.NET 4.0

More evolution – but don’t panic !

The new stuff will very cool and compatible (if you’re going to PDC or MIX you may see sneak peeks) – but most of all SIMPLE and POWERFUL !

Everyone always wants to talk about innovation, but clever evolution is every bit as exciting to me (and the lines between the two are grey anyway)

As for me, I’ll still be doing Web Forms, but I’ll be learning MVC and I’ll be chomping at the bit waiting until I can start showing you the V.after_4 stuff !

After a week looking at some longer term plans for ASP.NET – I’M PUMPED to be on the best train for web developers !!!

 

Technorati Tags: Microsoft ASP.NET MVC Future

PHP Linux Windows ASP.NET Performance – Redux !

UPDATE: This is a followup – please read the roogiional – and remember, these tests are NOT Microsoft official and NOT endoursed by my Employer.

Last week I posted some comparative performance result that I got from comparing the relative performance of PHP on PHP 5.2 to PHP 5.3, PHP on Linux to PHP on Windows and PHP to ASP.NET.

First, I want to thank the PHP community for their responses. With only a few exceptions the PHP community proved that they are not a bunch of teenage jealous (anymore :) ? ) but rather a group of professionals, confident in their work and ready to engage in respectful dialog.

A couple of my friends in the PHP community (See: to Andi Gutmans & Brandon Savage) took exception to the perf results – and for fair reason.

In my tests I declined to install PHP op-code caching for my tests because its not installed on some of the hosts I use and is not built in to PHP (yet – though I understand it will be in a future version and is part of Zend’s free Community Edition Server)

Andi, Brandon, and other pointed out that in business application deployment, most PHP shops use op code caching, so I installed it on Linux and Windows and re-ran most of the tests.

Note that the PHP 5.3 with APC tests were run on a clean Debian 5 setup on the same hardware and running the same code. I moved to Debian because building on Ubutu was giving me dependency fits. You’ll note that the performance delta between Ubuntu and Debian was negligible.

You can click on the image below to see the whole updated times table.

8-13-2009 9-26-43 AM

[ Click here for the whole table. ]

Some items showed a small improvement in performance, some stuff up to 25% faster, but overall it was far less than I expected.

Some things ran slower with APC but I attribute that to simple machine variance. (Note, the numbers in the table are NOT the first page run. I loaded the page, refreshed twice to make sure to hit the cache and then took the numeric results.)

Some folks suggested that these weren’t “fair” tests.

I disagree.

An empty loop test or an empty function call, for example, is very important because the results indicate language or platform OVERHEAD. That overhead is addition latency in page delivery and this, if it exists, is an important consideration.

A few of my PHP friends concede the accuracy of the results but made very insightful comments.

I’ll paraphrase them here.

  • The amount by which ASP.NET is faster than PHP doesn’t matter to me. PHP is simply my preference and it’s fast enough in my applications.
  • Sure, ASP.NET might be faster in raw execution but in my web applications I can easily buy that performance back with good page and JavaScript practices.
  • I build on Drupal and I know PHP best so what I might need to spend on more hardware I make up for in developer productivity.

These are all excellent points !

Though I think the tests that I’ve run so faw are fair, they are incomplete and their incompleteness prevents us from seeing the whole story.

Contrary to the couple of inevitable allegations that I’m “just” a Microsoft shill. I’m doing this because I want to KNOW.

My last tests revealed things like PHP file access and MySQL access on Windows has real performance issues and this information was received by the various teams involved here at Microsoft. They are following up and hopefully the data will directly result in improvements.

So – HERE IS YOUR CALL TO ACTION.

Use the contact form http://misfitgeek.com/contact/ and tell me what tests you would like me to run in order to grow my test suite in ways that you think are fair and meaningful.

Here are some of what I’m planning.

  • Real Page tests – loops, calls, and object instantiation are one kind of test, but full page rendering is another meaningful benchmark.
  • Load tests – can one environment or another handle more simultaneous requests.
  • During Simultaneous requests, does one stack degrade performance more than another.
  • In the above context – how much does 64 bit matter on each platform

I hope you’ll send me your suggestions.

Technorati Tags: Microsoft Windows C# ASP.NET PHP Linux Performance Benchmarks
  •  

Telerik Extensions for ASP.NET MVC

datepicker

One of the big strengths of ASP.NET is the huge number of high quality 3rd party augmentations to ASP.NET.

Well, the venders are starting to show ASP.NET MVC Offerings.

[ Check out Telerik’s HERE ]

 

Technorati Tags: Microsoft ASP.NET MVC Telerik Controls

Those Slackers are at it again – Stackoverflow Inspired Open Source Clone

Sonu Kapoor (DotNetSlackers.com) is working with Andrew Siemer to create a create a series of articles to recreate the StackOverflow website (of course with the permissions of the SackOverflow guys).

The first article went live yesterday and others are coming very soon.

I thought I would share this with you in the hopes that you will get involved.

Here is the first article:
http://dotnetslackers.com/articles/aspnet/Building-a-StackOverflow-inspired-Knowledge-Exchange-Introduction.aspx

Here is the index (under construction):
http://dotnetslackers.com/projects/StackOverflowInspiredKnowledgeExchange/

The source-code will be hosted on codeplex:
http://knowledgeexchange.codeplex.com/

Comments on my recent benchmarks.

Overall I’ve been pretty impressed with the reactions to my first round of PHP/Linux/Windows/ASP.NET performance tests.
I’d like to comment of the comments  

First, while I appreciate the enthusiasm of my .NET friends, the point of my exercise was to give me (and other folks at Microsoft) a starting place to understand some things about the performance of PHP on Windows and of ASP.NET.

If your faith in ASP.NET is incrementally sustained by virtue of this data than I’m happy. If I didn’t think that .NET was a as good as or better than any other technology for building web applications then I wouldn’t be working here at Microsoft.

But …..  It is incorrect and naïve to use this little bit of data to discount PHP out of hand.

I have much more work to do and there are many considerations.

  • These are BASE performance data. It is unwise to take a little bit of favorable data and use it to make sweeping conclusions.
  • There are many more performance factors we need to research.
  • PHP as a core technology easily scales out with hardware additions, hardware can often be considered cheap under the right circumstances.
  • Though my environment emulates my shared Linux host, enterprises will use op-code caching and we should consider this scenario (test results coming soon.)

My goal isn’t to show PHP on Windows is faster than PHP on Linux – my goal is for PHP on Windows to ACTUALLY BE faster. The same with ASP.NET. These tests have provided useful data to some of our internal feature guys already and they are taking action as a result.

Here are some general statements, assumptions, etc and my responses.

  • “I would utilize ASP.net simply because I like the Visual Studio IDE” – I personally think Visual Studio is far and away the very best, most productive developers IDE ever made. But, there are some pretty good ones for PHP. I use Zend Studio, PHPEd, Komodo, Delphi for PHP and all are great. I loathe Eclipse, but Zend has done a good job extending it for PHP Developers.
  • In regards for requests to compare the performance of Classic ASP to ASP.NET – No thanks !!!!!  Classic ASP is not nearly the development technology or EITHER today’s PHP or ASP.NET. To do a comparison is to suggest that folks might do new development in Classic ASP and I couldn’t recommend more strongly that you move n from Classic ASP.
  • 32 bit versus 64 bit ? – The nature of these tests would likely not show any statistically significant differences by the additional address space of 64 bit. In future tests where I add load simulations, I will add 64 bit scenarios to the tests.
  • “PHP is ugly like hell” – Oh, I beg to differ. Classic ASP was MUCH uglier !! You can write terrible and ugly PHP code. As you can write terrible and ugly C# and VB code. On the other hand, you can write very elegant C++ style code in PHP. It is completely a factor of the developers skills and attention to detail.
  • Adding Apache on Windows to the tests. – No thanks. Apache is THE server on Linux but IMO, you’re missing out on a TON of opportunity if you don’t use IIS 7.x on Windows !
  • “Adding a XAML/Silverlight comparison would be a good idea.” – This would be interesting, but a little out of scope. First, the tests would only be interesting if we compared the performance of logic that could be run EITHER server or client side. Then, in addition to the server side execution performance I would need to duplicate the tests in Adobe Flash and JavaFX in order to be really meaningful.  I’ll add it to my list for a later set of tests.
  • “Is there a way to improve the performance of the file copy test on Win2k8 ASP.Net 2 without compromising security?” – Probably not. I think this has to do with the ACL system used by Windows Server. I might test the performance reading and writing files through streams to compare the performance. Some things will just be faster on one side or the other; luckily, mass programmatic file copy operations aren’t too common for web applications.
  • “PHP has always been, and will always be, tailored to semi-professional environments.” – No disrespect, but this is simply bullshit ! There are MANY professional / high quality sites and applications written in PHP and there are many PHP developers who’s work I greatly respect. Professional / Not professional is a factor of the developer’s skill, not PHP or ASP.NET
  • “But Linux is Free” – Well…….  This is a great topic for discussion. I’ll get to it in a bit   
  • “I don’t think it’s fair to compare PHP without an opcode cache… You can’t compare an opcode cache to page caching. .Net has the benefit of using bytecode, while PHP has to parse the file and "compile" for each page request. So you deny PHP the advantage that .Net has” – I agree this test is necessary for completeness, but I’m not sure the logic holds. I tested PHP as you would download and install it. My shared host does not have op-code caching installed. The fact that it’s built in to ASP.NET and not PHP doesn’t make my test unfair, it’s MISSING from PHP. That said- the request is valid and I’m working on it.
  • “Please add Perl, Python, Ruby, etc.” – Someday I might, but these web development options are relatively unimportant (to me) since the developer market share of these are still just a tiny fraction of that held by ASP.NET and PHP. (I am more interested in JSP though.)
  • “if you get around to doing that kind of test, you should probably account for the fact that it typically takes hours to set up and configure a Windows server (while most Linux sysadmins can do it in under 10 minutes).” – This just isn’t true. EXPERIENCED Windows and Linux Admins can do equally impressive things deploying servers within their respective areas of expertise.
  • “Saying that PHP isn’t a "professional" language is just dippy, since nearly all of the largest web sites in the world today were built with PHP.” – It is dippy, but it’s also WRONG to say that “nearly all” are built with PHP. Some are, some aren’t.
  • “Why didn’t you use Zend Page Cache to negate that effect to bring it to an equal footing with ASP.NET?” – As mentioned above. It’s not part of core PHP, the exercise wasn’t to do a bunch of custom stuff to get PHP to be as fast as ASP.NET, though as I mentioned, I’m going to work on an test with Op-Code caching.
  • “What about Mono” – Email Miguel, he probably already has some relevant data.
  • Exo – you’re a jerk   :)
  • “Win + ASP.NET + MySQLWin + ASP.NET + PostgreSQL” – Yep !!! These are in the works !!
     

There were another couple of interesting comments ….
 

“I’m not a developer I’m a user.”

… and

“most of these (PHP)  projects are perfect examples of heavy spaghetti, anti-pattern software.”

From a pure technology perspective, I find .NET to be far more powerful than PHP, but that doesn’t mean PHP is not powerful.

IMO, PHP’s power is in the network of applications and frameworks that are available.

Though many PHP “users” are “real” developers, many are as the commenter suggests, “Not developers, but rather users”.

As to the second quote, sure, I’ve looked at lots of ugly PHP code.  I’ve done lots of work with PHP-Nuke and PHPBB and neither is coded in an elegant or OOP way.

But, both those applications ROCK !!!!  Lots of the PHP-Nuke code is UGLY, but it works !!!  (A lot of the world’s business systems are still running on really UGLY COBOL code.)

I used PHP-Nuke for years and made a habit of sing a code formatter and cleaning up modules or pages as I “touched” them.

Though both PHPBB and PHP-Nuke are “out of favor” I still use and love them. I also now use and love Drupal, Joomla, SMF, and VBulletin, as well as many others.

THIS !!! Is why I’ve been on this 8 year mission to get PHP on Windows working well and to get PHP and .NET working together !!  I wanna use PHP applications and have access to the amazing power that is .NET

So, that’s a lot of rambling, but there is one more topic that I deferred higher up in this text.

TCO ! ?

Craig asks a GREAT question – “ …. isn’t it TCO that counts?”

Yup !

Total “cost” is a factor of SO many thing.

Microsoft can convincingly and truthfully explain to you why .NET offers that best TCO ratio !!!!

The problem is, Zend can truthfully explain to you why PHP offers that best TCO ratio.

Everyone who dislikes the state of ANY technology comparison bails out to fuzzy TCO claims.

I’ll get to TCO data that is perf/scale based (after much more testing.)

I’d be very interested in seeing any REAL data either way.

In any event – thanks for reading. More to come !

[ You can read the original post HERE ]

Microsoft now owns Office.com

Some one sent me this. I have no internal knowledge about it. But it’s interesting food for thought.

Especially when you couple it with this http://news.cnet.com/8301-13860_3-10076883-56.html?tag=mncol;txt

I think this will open up some really interesting opportunities for web developers.

See it for yourself at http://www.whois.net/whois/office.com’

Registrant:
        Domain Administrator
        Microsoft Corporation
        One Microsoft Way
         Redmond WA 98052
        domains@microsoft.com +1.4258828080 Fax: +1.4259367329

    Domain Name: office.com

    Administrative Contact:
        Domain Administrator
        Microsoft Corporation
        One Microsoft Way
         Redmond WA 98052 
        domains@microsoft.com +1.4258828080 Fax: +1.4259367329

    Technical Contact, Zone Contact:
        MSN Hostmaster
        Microsoft Corporation
        One Microsoft Way
         Redmond WA 98052
        msnhst@microsoft.com +1.4258828080 Fax: +1.4259367329

    Created on…………..: 1999-04-19.
    Expires on…………..: 2019-04-19.
    Record last updated on..: 2009-08-04.

PHP versus ASP.NET – Windows versus Linux – Who’s the fastest ?

NOTE: This is “Misfit Data” – While I do work for Microsoft, this data is NOT “official Microsoft” data and is not endorsed or ratified by Microsoft in any way. I built and ran these tests because I was personally curious about comparative performance.

If these test results cause you dizziness, vomiting, or other undesired side effects, please discontinue use immediately and consult your physician.

How does IMPLEMENTATION Performance Compare ?

Usually, when someone creates benchmarks, they are trying to prove that their thing is faster than someone else’s thing.

I’m PAID by Microsoft to write BOTH PHP and ASP.NET Code. I was doing PHP before .NET shipped. I love them both.

This makes it hard for me to say anything good about either one. When I confer a preference for something in PHP, my Microsoft peers send me flame mail and when I confer a preference for something in ASP.NET, my PHP friends come out of the woodwork to call me a Microsoft shill.

I started building and running these tests because everyone had opinions about comparative PHP performance (Windows versus Linux & 5.2 versus 5.3), but no one had any solid data.

So, I decided to collect some empirical evidence of my own.

[ You can CLICK HERE to see the result spreadsheet. ]

Before you look at them, let m e provide some method details and context.

All tests were run on the SAME Machine.

A Toshiba Tecra M5 with 4 Gig of ram and a 60 Gig 7200 RPM Hard Drive.

Ubuntu 9 and Windows Server 2008 Standard were natively installed on 2 separate (but identical) hard drives.

The web servers were Apache2 on Linux and IIS 7 on Windows.

Both operating systems were fully patched / updated.

No Operating System or Development Runtime performance enhancements were added.

I wasn’t investigating how much speed an expert could custom tailor the tests to on a specific platform.

Yes, I could implement PHP Byte Caching, or for ASP.NET I could use Page Caching, Partial Page Caching, SQL Cache Dependency, Multi Threading, etc.

Both Windows and Linux Implementations of PHP will benefit from PHP Byte Code caching.

My goal was to determine the relative speed of THE IMPLEMENTATION.

I found the results both interesting and unexpected.

PHP on Linux Versus PHP on Windows…..

I really though one would just be faster than the other, but I was wrong. Some things are faster on Windows, other are faster on Linux.

  • RAW statement execution seems faster on Windows.
  • Function Calls were faster on Windows
  • Object Creation / Access was faster on Linux with PHP 5.2 but faster on Windows with 5.3
  • Library calls were faster on Linux. (Example: Encryption 3-5 times faster on Ubuntu.)
  • File Access is faster on Linux by a small percentage, except for file copy operations which was as much as 60% slower on Windows probably due to the ACL advanced security.
  • MySQL access with Linux is faster by more than a little and on Windows, MySQL access deteriorates in version 5.3 (This seems to be poor implementation, see PostgreSQL below.)
  • PostgreSQL performance is very close on both platforms (within 6/100 of a second for 1000 Operations) – It’s faster on Windows and faster still on Windows with PHP 5.3
  • MS SQL Server access from PHP 5.2 on Windows is marginally slower than MySQL access on Linux. (PHP 5.3 not yet supported at the time of this writing.)

So what does all that mean ?

  • We can probably say that in terms of raw execution – performance on Linux versus Windows is probably a wash (more or less equivalent) so that the performance of PHP itself becomes a moot factor in choosing Linux or Windows for PHP application deployment.
  • If you are building an application, or running an application that supports it, PostgreSQL might be a better database choice since it performs pretty much the same on Windows and Linux.
  • If you are running an application that locks you in to Sun Microsystems’ MySQL and you want to run it on Windows, your should do scale planning. (My personal guess is that it’s unlikely that Sun will markedly improve MySQL performance on Windows. )
  • Version 1 of the PHP Driver for SQL Server (V2 is in the works) is somewhat slower than MySQL or PostpreSQL but probably not enough to discourage use where diverse developer access is desired. (v2 ot the driver will improve performance. )

By and large I think the PHP team and the Microsoft IIS team have accomplished good raw performance equivalence across platforms. (Now we just need to get the Open Source Application teams (Drupal, WordPress, Joomle, etc.) to do performance optimization on both !)

PHP versus ASP.NET Raw Performance …..

By now you have cheated and looked at the spread sheet.

Yes, ASP.NET is universally faster than PHP (on Windows and on Linux) with the exceptions of File Copy and Attribute operations.

MySQL Access from PHP on Linux is a TINY bit faster than SQL Server access on Windows (assuming common data types and SELECT statements) but probably not enough to matter.

ASP.NET (C#) operations, object use, library calls, etc. are SIGNIFICANTLY faster that the PHP equivalents. 

I know my PHP friends and the Linux dudes (and dude-etts) will probably come out of the wood work to refute my tests and results :)  

I’ve always thought that if high end performance options were part of your needs requirements,  then .NET programming has some advanced options “out of the box” like multi-threading, asynchronous requests, and a number of caching options.

NOTE – I’m not saying “ASP.NET is Faster so you shouldn’t choose PHP !!!!  I’ve always contended that the affable simplicity of PHP had some drawbacks for certain advanced applications. (Just as the early learning complexity of ASP.NET can have it’s drawbacks. )

To me (your mileage may vary) the exciting thing about PHP is not the language / platform so much as it is what thousands of clever PHP Developers have done with it (Drupal, Joomla, WordPress, PHPBB, Nuke, etc.)

In any event, it’s nice to now have some data that PHP performance on Windows and Linux are “in the same ballpark”.

Now I can start writing those Windows specific PHP  libraries I’ve been dreaming about for years !!

COMMENT WARNING

  • I know some will be incensed by these tests. You are welcome to comment and disagree, but if you can’t be polite I’ll simply delete your comments and block your IP address.
  • If you dislike the results and want to refute them – DO THE WORK. Accompany your dissent with DATA. Take my code or write your own and argue with FACTS.

You can look at the code here.

  • PHP Perf Test – MySQL
  • PHP Perf Test – PostgreSQL
  • PHP Perf Test – SQL Server
  • ASP.NET Perf Test
  •  SQL Database Setup

Anyway – hope some of you find this interesting.

Now let the frenzy begin !!

 

Technorati Tags: ,ASP.NETOOP,,,,Postgress,,

Free eBook – Developer-Evangelism.com

My first job at Microsoft was as a developer evangelist.

The company I ran before I came to Microsoft did a great deal of “technical evangelism” for ASP, Java, Flash, and others.

And many of the folks who read my blog are “Technical Evangelists”, either as part of their job, or in their work with their developer community of choice.

So – I wanted to share this super (and free) eBook.

http://developer-evangelism.com/

I love the part on “Remove the Brand”.

Hope you enjoy it !

 

The patterns & practices team plans to create some new Web guidance and we need your help prioritizing the requirements through a survey that just went live.

They have split the effort into 2 projects.

The first project will be to update the Web Client Software Factory (WCSF) to run on Visual Studio 2010.

The second project will take a fresh look at creating new Web Guidance.

Your feedback from the survey will help define the scope for this second project.

So, go take the survey and let us know your priorities.

[ CLICK HERE TO TAKE THE SURVEY ]

Adding Persistence to the .NETOOP Edit in Place control.

I’ve added persistence to the “In-Place-Editor” control at .NETOOP  using SQLExpress and the LINQ to Entities.

Since the Control itself can be used for ANY text content, the page that contains the control is responsible for population and persistence.

Note the code below. The control is populated by the first notice in the notices table (other use may use multiple records.)

Of particular interest is the push back to the database.

Note that this code is called from the Page_SaveStateComplete event handler.


NETOOP_DataEntities ctx = new NETOOP_DataEntities();
protected void Page_Load(object sender, EventArgs e)
{
// Populate the In-Place Editor Control
var result = ctx.NETOOP_AnnouncementSet.Where(p => p.Id == 1);
if (!IsPostBack)
{
NETOOPNoticeEditor.Content = result.First().ContentText;
}
}
 
protected void Page_SaveStateComplete(object sender, EventArgs e)
{
// Push Edited Changes back to the database. 
// This can NOT be done in the Page_Load event becuase the 
// "DataDirty" flag gets set in a control event which doesn't
// fire until after Page_Load
if (NETOOPNoticeEditor.ContentIsDirty)
{
var result = ctx.NETOOP_AnnouncementSet.Where(p => p.Id == 1);
result.First().ContentText = NETOOPNoticeEditor.Content;
ctx.SaveChanges();
}
}

It needs to be done here because the dirty content flag is set in the Editor Control’s “ContentChanged” event handler.


protected void ContentEditor_ContentChanged(object sender, EventArgs e)
{
ContentIsDirty = true;
ViewState[this.ID.ToString()] = ContentEditor.Content;
Content = ContentEditor.Content;
}

The ContentChanged event fires AFTER the Page_Load event so we need to move the “Save” call to later in the Lifecycle.

Note also the explicit ViiewState population which is necessary to maintain the user edits on post-back.

Some MISSING items …… 

  • Save Exception Handling
  • Safari / Chrome Support (This is a multi-view control issue.)
  • Security – (No role constraints, anyone can edit.)
  • Multiple Announcement Record Support

 

Technorati Tags: ,,NETOOP,,

Using the ASP.NET AJAX Editor Control to Implement In-Place Content Editing.

In-Place editing is a slick feature for managing some of a web sites content.

I’ve mocked up a demo of In-Place editing using the new ASP.NET Ajax Control Toolkit’s Editor control and the ASP.NET Multi-View control.

Also, I’m implementing this as a User Control so it can be easily and widely used throughout my project.

Here’s how it works.

Note the little “Pencil” on the top / right of the content are. If you hover over it you get an edit hint.

7-9-2009 10-49-53 AM 

When you click on it you enter edit mode.

Note the Ajax style behavior accomplished by a combination of using ASP.NET’s MultiView control and ASP.NET Ajax’s UpdatePanel.

7-9-2009 10-50-39 AM

Now some rich text entry.

7-9-2009 10-52-33 AM

Clicking on the Floppy Disk Icon “Saves” the new content (actual persistence is not yet implemented) and clicking on the X cancels.

Hovering over the icons provides guidance. Note that the Editor Sizes with the text area. 

Click save and ….

7-9-2009 10-52-54 AM

Presto.

Here are a few implementation details …..

First, lets look at the control in design view.

7-9-2009 11-12-16 AM

… the markup

   1:  <asp:UpdatePanel ID="InPlaceEditorCOntrolUpdatePanel" runat="server">
   2:  <ContentTemplate>
   3:  <asp:MultiView ID="EditInPlace_MultiView" runat="server" ActiveViewIndex="0">
   4:     <asp:View ID="DisplayView" runat="server">
   5:         <asp:Panel ID="ContentDisplayPanel" runat="server">
   6:         <p style="text-align: right">
   7:            <asp:ImageButton ID="Edit_ImageButton" runat="server" Height="16px"
   8:                          ImageUrl="~/InPlaceEditorControl/Images/Edit_Icon.png"
   9:                          Width="16px"
  10:                          ToolTip="Click to Enter Edit Mode"
  11:                          onclick="Edit_ImageButton_Click" />
  12:         </p>
  13:         <asp:Label ID="ContentLabel" runat="server" Width="100%"></asp:Label>
  14:         </asp:Panel>
  15:     </asp:View>
  16:     <asp:View ID="EditView" runat="server">
  17:         <asp:Panel ID="ContentEditPanel" runat="server">
  18:         <p style="text-align: right">
  19:            <asp:ImageButton ID="Save_ImageButton" runat="server" Height="16px"
  20:                          ImageUrl="~/InPlaceEditorControl/Images/Save_Icon.png"
  21:                          Width="16px"
  22:                          ToolTip="Click to SAVE and Exit Edit Mode."
  23:                          onclick="Save_ImageButton_Click"
  24:                             />
  25:            <asp:ImageButton ID="Abort_ImageButton" runat="server" Height="16px"
  26:                          ImageUrl="~/InPlaceEditorControl/Images/Abort_Icon.png"
  27:                          Width="16px"
  28:                          ToolTip="Click to Exit Edit Mode Without Saving."
  29:                          onclick="Abort_ImageButton_Click" />
  30:         </p>
  31:         <act:Editor ID="ContentEditor" runat="server" Width="100%" Height="100%"
  32:                 oncontentchanged="ContentEditor_ContentChanged" />
  33:         </asp:Panel>
  34:     </asp:View>
  35:  </asp:MultiView>
  36:  </ContentTemplate>
  37:  </asp:UpdatePanel>

… and the code.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Web;
   5:  using System.Web.UI;
   6:  using System.Web.UI.WebControls;
   7:   
   8:  public partial class InPlaceRichTextEditorControl : System.Web.UI.UserControl
   9:  {
  10:   
  11:      private int _ContentHeight;
  12:      public int ContentHeight
  13:      {
  14:          get
  15:          {
  16:              return _ContentHeight;
  17:          }
  18:          set
  19:          {
  20:              _ContentHeight = value;
  21:          }
  22:      }
  23:   
  24:      private int _ContentWidth;
  25:      public int ContentWidth
  26:      {
  27:          get
  28:          {
  29:              return _ContentWidth;
  30:          }
  31:          set
  32:          {
  33:              _ContentWidth = value;
  34:              ContentDisplayPanel.Width = _ContentWidth;
  35:              ContentEditPanel.Width = _ContentWidth;
  36:          }
  37:      }
  38:   
  39:      protected void Page_Load(object sender, EventArgs e)
  40:      {
  41:  
  42:      }
  43:   
  44:      protected void Edit_ImageButton_Click(object sender, ImageClickEventArgs e)
  45:      {
  46:          ContentEditor.Content = ContentLabel.Text;
  47:          EditInPlace_MultiView.SetActiveView(EditView);
  48:      }
  49:   
  50:   
  51:   
  52:      protected void Abort_ImageButton_Click(object sender, ImageClickEventArgs e)
  53:      {
  54:          EditInPlace_MultiView.SetActiveView(DisplayView);
  55:      }
  56:   
  57:      protected void Save_ImageButton_Click(object sender, ImageClickEventArgs e)
  58:      {
  59:          ContentLabel.Text = ContentEditor.Content;
  60:          EditInPlace_MultiView.SetActiveView(DisplayView);
  61:      }
  62:      protected void ContentEditor_ContentChanged(object sender, EventArgs e)
  63:      {
  64:   
  65:      }
  66:  }

And yes, I think this is NOT FINISHED.

Thoughts, suggestions ?

Technorati Tags: ,,NETOOP,

TODAY ONLY – Win a free pass to the Patterns & Practices Summit

Telerik is  giving away a free pass to the 2009 PNP Summit ($1900 value) along with a Telerik Premium Collection license TODAY.

To be in the drawing for the big prize, you need to attend the last of “Release Week Webinars”

TODAY at 11 AM Eastern

(Details: http://telerikwatch.com/2009/07/telerik-q2-2009-webinar-week-prize.html).

They will select the winner this afternoon and make an announcement.

They  are also giving away another Telerik Premium Collection license to one randomly selected “tweeter” TODAY.

You just need to tweet with “#telerikq209” to be in the drawing.

GOOD LUCK

ASP.NET Mini-URL on CodePlex

miniurl_main

Here is a sample ASP.NET MVC application to show how to create URL shrink/snippet/etc and handling of shorten URLs.

The purpose of this sample project is to show developers how simple it is to create a simple URL redirection service like tinyurl, is.gd or snurl. To get a full listing of all available URL redirection services, check out the open directory listing.

I thought it was interesting and thought you might too.

Technorati Tags: ,ASP.NETOOP,

NoSQL ? Or do you SQL Everything ?

NoSQL

Computerworld ran a story on July 1 “No to SQL? Anti-database movement

There have been many performance oriented technologies and enhancements relieved recently.

And some 3rd part solutions like NoSQL

…. but there are also free SQL Databases

Since cost scales down to zero and resource needs go from huge to very lightweight the choice seems to me to be primarily preferential.

 

As I’m getting more into LINQ I’m liking the LINQ model (though Linq-to-XMl with XQuery works for me) and I see few instances with my applications can’t benefit from a SQL Database, I’m wondering what the community this of the NoSQL thing?

Tell me !

Proving the performance of Static Properties.

I don’t claim to be the best developer on the planet :) but I’m always amazed at how all the “experts” come out of the woodwork to posh on other peoples code :)

Several folks have commented and emailed about hey the technique I posted earlier was unnecessary. But only ONE guy (thanks Henrik Juhlin) took the time to research before commenting.

Since the last company that I built did nothing but performance work, it did get me thinking, so I built a little test.

I used 4 potential access methods and ran the test with debugging OFF!

Here are the results.

Retrieve and Assign 200,000 Times

From Application Object : 1797 Milliseconds

From Config File : 1699 Milliseconds

From Resource File : 684 Milliseconds

From Static Variable : 5 Milliseconds

In a real production environment there are, of course, additional factors to consider, but from a pure retrieval perspective, that makes the Static Instance property like 340 TIMES faster than reading from the config file.

Here is the code.

   1:  static public string MySiteName { get; set; }
   2:    
   3:  protected void Page_Load(object sender, EventArgs e)
   4:  {
   5:      Application["SiteName"] = "This is s Test";
   6:      MySiteName = WebConfigurationManager.AppSettings.Get("SiteName");
   7:   
   8:   
   9:  }
  10:   
  11:  protected void Button1_Click(object sender, EventArgs e)
  12:  {
  13:      
  14:      string MyString = "This is a string test ";
  15:      long StartTime;
  16:      long EndTime;
  17:      long ElapsedTime; 
  18:      
  19:      // App Setting 
  20:      StartTime = DateTime.Now.Ticks;
  21:      for (long i = 0; i < 2000000; i++)
  22:      {
  23:          MyString = WebConfigurationManager.AppSettings.Get("SiteName");
  24:      }
  25:      EndTime = DateTime.Now.Ticks;
  26:      ElapsedTime = EndTime - StartTime;
  27:      ElapsedTime = ElapsedTime / 10000;
  28:      Label1.Text = ElapsedTime.ToString();
  29:   
  30:      // Resource File  
  31:      StartTime = DateTime.Now.Ticks;
  32:      for (long i = 0; i < 2000000; i++)
  33:      {
  34:          MyString = GetLocalResourceObject("Resource1.Text").ToString();   
  35:      }
  36:      EndTime = DateTime.Now.Ticks;
  37:      ElapsedTime = EndTime - StartTime;
  38:      ElapsedTime = ElapsedTime / 10000;
  39:      Label2.Text = ElapsedTime.ToString();
  40:   
  41:      // Application Object 
  42:      StartTime = DateTime.Now.Ticks;
  43:      for (long i = 0; i < 2000000; i++)
  44:      {
  45:          MyString = Application["SiteName"].ToString();
  46:      }
  47:      EndTime = DateTime.Now.Ticks;
  48:      ElapsedTime = EndTime - StartTime;
  49:      ElapsedTime = ElapsedTime / 10000;
  50:      Label3.Text = ElapsedTime.ToString();
  51:   
  52:      // Static Variable  
  53:      StartTime = DateTime.Now.Ticks;
  54:      for (long i = 0; i < 2000000; i++)
  55:      {
  56:          MyString = MySiteName;
  57:      }
  58:      EndTime = DateTime.Now.Ticks;
  59:      ElapsedTime = EndTime - StartTime;
  60:      ElapsedTime = ElapsedTime / 10000;
  61:      Label4.Text = ElapsedTime.ToString();
  62:  }

 

Technorati Tags: ,,

thrive_300x250 Thrive – a one-stop community hub that offers job postings, technical content, and community resources.

Microsoft understands that today’s economy is challenging for developers.

You’re stretching your skills, looking for work, or searching for efficient solutions to unfamiliar tasks.

That’s why we created Thrive.

It’s a one-stop community hub that delivers career advice, training programs, peer insights and job postings.

You’ll also find tools to help you connect with other smart coders in your local area.

Get the resources you need to tackle the recession head-on.

www.microsoft.com/thrivedev

 

Blumin’ Dynamic Data !

Peter_Blum_anilogo

So there is this guy in the ASP.NET Community named Peter Blum who writes great ASP.NET Controls.

One of the control sets he offers is a Data Entry Suite with ASP.NET Dynamic Data support.

I want to share the link because, apart from the controls being great, there is also useful info on Dynamic Data

http://www.peterblum.com/des/dynamicdata.aspx

 

Technorati Tags: ,ASP.NETOOP,

Global Application settings and the web.config file.

While getting started on .NETOOP, one of the first issues to address is that of “Global” settings.

When you build a web application for a single purpose, you can hard-code things without much concern.

Microsoft.com is probably always going to have the same name, but .NETOOP is going to be a portal application. Everyone who uses the application will need to .NETOOP to use their own web site name (and lots of other site specific configuration data.)

Now ASP.NET has that clever “Application Settings” feature. This is a great feature that includes design time setting creating and a well factored API for reading the settings.

The problem is that these settings like “Site Name” are going to be used all over the site and the actual settings are stored in the web.config file.

Reading the .xml file several times for each page lifecycle would be VERY bad for performance.

By the way, if your worried about WRITING to the web.config file, you are right. When you save changes to a web.config file the application needs to be reset, so you defiantly do not want to do much writing to the web.config file since it will kill performance and screw up session state for in session users.

In our case we are talking about global configuration settings which will be set up when the site is originally configured and will very seldom, if ever, be changed after deployment. So the write issue is a moot point for our requirements but the READ FREQUENCY is still a big issue.

As we’re building .NETOOP we really want to take advantage of ASP.NET services, but we want the application to scale VERY well.

At first I thought perhaps the right solution was to implement a new Settings Provider that uses SQL Server as described [ HERE ]

We’ll probably have to revisit the custom provider when we implement profiles but it seemed over kill for our needs and I think I’ve implemented a better solution with less work.

Innate property caching !

Given the application settings in the following web.config snippet……

<appSettings>
<add key="SiteName" value="NETOOP Site Name" />
<add key="SiteOwner" value="NETOOP Site Owner" />
</appSettings>

We need a way for the values to be accessible and not have that access degrade performance.

Now, one of the things you may be thinking is that an application object may be a great place for this kind of data.

I’ve opted NOT to use an Application scoped object because there is a certain usage scenario that is ill-served by this.

Example: The “Title” and “MetaData” of each page should be unique and dynamic, but should include the data from the Application Setting.

So, here is my solution ….

First, a static class to contain the site’s global settings.


using System;
using System.Web;
using System.Web.Configuration;
 
/// <summary>
/// SiteGlobalSettings is used to "cache" settings that are used globally and frequently
/// and are stored in the applications settings section of the web.config file.
/// This was the web.config file does not have to be read from disk each time a 
/// "Site Wide Setting' needs to be accessed. 
/// When changes are made to the web.config file, the appdomain will be reset so the 
/// static constructor will be run when the application restarts and the new values will 
/// be retrieved. 
/// </summary>
public static class SiteGlobalSettings
{
static public string MySiteName { get; set; }
static public string MySiteOwner { get; set; }
 
 
static SiteGlobalSettings()
{

MySiteName = WebConfigurationManager.AppSettings.Get("SiteName");
MySiteOwner = WebConfigurationManager.AppSettings.Get("SiteOwner");
 
}
}
 

This means that these values will be retrieved when the application receives it’s FIRST request for a page that uses this class, the constructor is only called ONCE, which means the web.config files only needs to be accessed once, and the class’s static properties stay in memory in between page requests.

Now I can use the global settings like this……

 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class _Default : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
 
if (null != SiteGlobalSettings.MySiteName)
Page.Header.Title = SiteGlobalSettings.MySiteName;
else
Page.Header.Title = "NETOOP - The .NET Object Oriented Portal";


}
}
 

Those this code is simply using the value from the web.config file as is, I could be appending some page specific data (and I will as I implement .NETOOP). I could also declare the page title as a static variable at the page level to improve performance even more.

Share your thoughts with me !!!

 

Technorati Tags: ,ASP.NETOOP,.NETOOP,,Application Settings

.NETOOP high level configuration storage decision.

In designing .NETOOP we have this issue:

Since .NETOOP will be an adaptable application designed to meet the needs of many users, some of the things that one might hard code in an application like “Web Site Name” will need to be set at installation time.

For “system”  configuration settings we have the web.config file.

For language and culture variations we have resource files.

But this type of site configuration doesn’t really  fit nicely into either of these categories.

We could use…….

  • web.config
  • .res files
  • .xml files
  • a table in the database.

There are a number of considerations.

  • Since these are not really the same kind of configurations issues that we normally put in the web.config file (like a connection string) it would seem that web.config is not the right place for them and it’s a good thing to minimize the number of times someone edits the web.config file. Even if we created web UI for editing these settings folks will hand edit it. It might grow large and I don’t even know you you can store MCBS strings in the web.config.
  • We could use resource files and create/edit them via System.Resources, but these file would not be “hand editable”.
  • .xml files are easy to edit but in an environment where the database and the web server run on different machines, I/O from a database will probably be faster. (Especially in lower end shared hosting environments.)
  • We could use a hybrid approach when edits are made in an XML file and imported into a database.
  • We could address performance issues by using one of the many ASP.NET caching facilities and storing some commonly used items in application state (like site title.)

Please take the poll at http://twtpoll.com/st6sa4.

I’m hoping to do some coding on this issue TONIGHT !

THANKS !

Technorati Tags: ,ASP.NETOOP,.NETOOP

6-15-2009 11-21-54 AM 

I saw this posted in a support forum …..

I can’t create New Project on my Visual Web Developer 2008 Express with SP1.

(I can only create New Website)

My colleague has the exact same version (if you go to Help – About) but they can create both New Website and New Project.

Did you install Visual Web Developer with SP1 and NOT get the “New Project” Options.

I did ! :)

Here is the fix.

 Go to “Tools –> Import and Export Settings.

ResetSettings-1234

 Select the BOTTOM Option “Reset All Settings”

6-15-2009 11-28-18 AM 

Click next and complete the wizard.

That’s it – “Projects” should now appear in your default view !

Contest – NETOOP Needs a Logo !

Visual identity is important. (Plus, you need something besides the url to put on a tee-shirt.)

Cool open source applications all have cool logos. Since this is a collaborative project and since I have NO artistic ability, I thought we could get some artistically capable folks involved in NETOOP by starting a logo contest. (Remember, good applications should be theme-able so were are going to NEED aesthetically creating folks involved after we implement a skinning and teeming strategy.)

So, if you have an idea for a log, email me a file (.png, .gif, .jpeg ONLY) .

I’ll create a wiki page and we’ll collectively decide which one to use.

When you email the file, include whether you want it posted with a URL or email address or not.

Technorati Tags: ,,,NETOOP

NETOOP – Codeplex or Self Host ?

For the NETOOP project we need to decide whether to use Codeplex or “Self Host”.

Codeplex ROCKS and provides Version Control, Bug Management, Release Management, Issue Tracker, Stats, etc.

You can read the FAQ here http://codeplex.codeplex.com/Wiki/View.aspx?title=CodePlex%20FAQ

If this were “just” an Open Source ASP.NET application this would be a no brainer for me – USE CODEPLEX.

But, since this is a “learning exercise” as much as an Open Source effort I want to ask.

Another consideration is that it’s easy for a customer to set up a nee CodePlex project but for a Microsoft employee to do it I need to go through a management review, and a legal review :(

So, Should we Codeplex or SelfHost ?

Please take the poll here. http://twtpoll.com/c6r8k8

Introducing NETOOP (The .NET Object Oriented Portal)

Yesterday I announced and new project I’m starting( READ HERE )

Since last night 40 people have joined the private wiki to participate in the collaborative design.

“The Project” now has a name and a domain !

NETOOP – the .NET Object Oriented Portal

www.netoop.com (Is were it will run……)

One of the commenters to my blog post asked,

What guiding patterns will you be using, and what technologies?

Is this an ASP.NET Ajax w/Linq to SQL thing?

Of course it will be ASP.NET and use Microsoft SQL Server but the rest is for us to discuss and decide.

In response to another question – ALL EXPERIENCE LEVELS ARE WELCOME.

One of the goals is for the end result to be ready to install, use, modify, and extend by ANY developer, so we NEED folks with all different experience levels.

You can sign up for a wiki account here [ Create Wiki Account ]

You can sign up for a forums account here [ Register for Forums Account ]

Join up – lets have some fun and do something cool  together !

 

Announcing the IIS SEO Toolkit (beta)

SEO-Toolkit-SMALL

Available for free download today !

Optimize your web sites for Search Engines !

Download the New IIS SEO Toolkit Beta

Today, we are announcing the IIS Search Engine Optimization (SEO) Toolkit Beta – a brand new free toolkit that helps Web developers, hosting providers, and server administrators improve their sites’ relevance in search results by recommending how to make them more search engine-friendly. The SEO Toolkit Beta is available for installation via the Microsoft Web Platform Installer 2.0 Beta at  http://www.microsoft.com/web/downloads/platform.aspx

The IIS SEO Toolkit can:
- Improve the volume and quality of traffic to Web site from search engines
- Control how search engines access and display Web content
- Inform search engines about locations that are available for indexing

The IIS SEO Toolkit includes three modules that integrate with IIS Manager: Site Analysis, which suggests changes that can help improve the volume and quality of traffic to your Web site from search engines; Robots Exclusion, which makes it easier to control and restrict the content that search engines index and display; and Sitemaps and Site Indexes, which can help inform search engines about locations that are available for indexing. The IIS SEO Toolkit Beta can be installed with the Microsoft Web Platform Installer 2.0 Beta for use with IIS 7.0 and IIS 7.5.

The IIS SEO Toolkit Beta is a piece of the larger Microsoft Web Platform strategy, which enables developers and end-users to build great websites, experiences, and achieve success in the Web ecosystem.

For more information visit: http://www.iis.net/extensions/SEOToolkit

Technorati Tags: ,,,

Dynamic IP Restrictions Extension for IIS 7.0

The IIS team has released the Dynamic IP Restrictions Extension for IIS 7.0 – Beta. The Dynamic IP Restrictions provides IT Professionals and Hosters a configurable module that helps mitigate or block Denial of Service Attacks or cracking of passwords through Brute-force by temporarily blocking Internet Protocol (IP) addresses of HTTP clients who follow a pattern that could be conducive to one of such attacks. This module can be configured such that the analysis and blocking could be done at the Web Server or the Web Site level.

Install the Dynamic IP Restrictions Beta Today!

Microsoft Dynamic IP Restrictions for IIS 7.0 – Beta (x86)

Microsoft Dynamic IP Restrictions for IIS 7.0 – Beta (x64)

If IIS already has IPv4 Address and IP restrictions module enabled then Dynamic IP Restrictions installer will need to un-install the existing module in order to continue the setup process. Note that the existing IPv4 configuration will be preserved while old module is removed and new module is installed.

Features

The Dynamic IP Restrictions includes these key features:

  • Blocking of IP addresses based on number of concurrent requests – If HTTP client makes many concurrent requests then that client’s IP address gets temporarily blocked.
  • Blocking of IP address based on number of requests over a period of time – If HTTP client makes many requests over short period of time then that client’s IP address gets temporarily blocked.
  • Various deny actions – it is possible to specify what response to return to an HTTP client whose IP address is blocked. The module can return status codes 403 and 404 or just drop the HTTP connection and do not return any response.
  • Logging of denied requests – all dynamically denied requests can be logged into a W3C formatted log file.
  • Displaying currently blocked IP addresses – a list of currently blocked IP addresses can be obtained by using IIS Manager or by using IIS RSCA API’s.
  • IPv6 – the module fully supports IPv6 addresses.

In additions to these features, the Dynamic IP Restrictions for IIS 7.0 provides the same functionality that exists in IIS 7.0 built-in IPv4 and Domain Restrictions. Because of that the Dynamic IP Restrictions is provided as a replacement for IPv4 and Domain Restrictions.

More information

Module walkthrough: http://learn.iis.net/page.aspx/548/using-dynamic-ip-restrictions/

Support forum: http://forums.iis.net/1043.aspx

Technorati Tags: ,,

Update on Windows Azure

Windows Azure has continued adding features since the last major update at MIX. 

Additional features and SDK updates will continue to roll out in the coming weeks and months.

Cool New Feature #1:  Geo-Location support

clip_image001

Starting in May, a new option was added to the portal to support geo-locating your code and data.  In order to use this most effectively, the idea of an ‘Affinity Group’ was created.  This allows you to associate various services under an umbrella label for the location.

Geo-Location is an important aspect of “Web 2.0” applications.

Read more about this feature here and see a complete provisioning walk-through.

 

Cool New Feature #2:  Storage API updates

Last Thursday (5/28), new features were released to the cloud for Windows Azure storage.  The long awaited batch transaction capability for tables as well as a new blob copying capability were released. 

Additionally, the GetBlockList API was updated to return both committed and uncommitted blocks in blob storage.

Also new versioning mechanism has been added. 

New features will be versioned by a new header (“x-ms-version”). 

This mechanism is in place to prevent breaking changes from impacting existing clients in the future.  It is recommended that you start including this header in all authenticated API calls.

Rounding out these updates were some changes to how property names are stored in table storage as well as the size for Partition and Row keys.  Unicode chars and up to 1K key sizes are now supported, respectively.  Finally, the timeout values for various storage operations were updated as well.

Please note:  There currently is no SDK support for these new storage features.

At this point, you need to use the samples provided on Steve Marx’s blog.  A later SDK update will add these features officially.

Windows Azure SDK Update

 

The May CTP SDK update has been released to the download center.  While this release does NOT support the new storage features, it does add a few new capabilities that will be of interest to the Visual Studio 2010 beta testers.

· Support for Visual Studio 2010 Beta 1 (templates, local dev fabric, etc.)

· Updated support for Visual Studio 2008 – you can now configure settings through the UI instead of munging XML files.

· Improved reliability of the local dev fabric for debugging

· Enhanced robustness and stability (aka bug fixes).

Download the Windows Azure Tools for Visual Studio (includes both SDK and tools).

New Windows Azure Applications and Demos

Windows Azure Management Tool (MMC)

The Windows Azure Management Tool was created to manage your storage accounts in Windows Azure. Developed as a managed MMC, the tool allows you to create and manage both blobs and queues. Easily create and manage containers, blobs, and permissions. Add and remove queues, inspect or add messages or empty queues as well.

Bid Now Sample

Bid Now is an online auction site designed to demonstrate how you can build highly scalable consumer applications.  This sample is built using Windows Azure and uses Windows Azure Storage. Auctions are processed using Windows Azure Queues and Worker Roles. Authentication is provided via Live Id.

 

PHP SDK for Windows Azure

As part of Microsoft’s commitment to Interoperability, this open source project is an effort bridge PHP developers to Windows Azure. PHPAzure is an open source project to provide software development kit for Windows Azure and Windows Azure Storage – Blobs, Tables & Queues

 

Relevant Blog Postings

 

http://blog.smarx.com/posts/sample-code-for-new-windows-azure-blob-features

http://blogs.msdn.com/jnak/archive/2009/05/28/may-ctp-of-the-windows-azure-tools-and-sdk-now-supports-visual-studio-2010-beta-1.aspx

http://blogs.msdn.com/jnak/archive/2009/04/30/windows-azure-geo-location-is-live.aspx

http://dunnry.com/blog/CreateAndDeployYourWindowsAzureServiceIn5Steps.aspx

 

Technorati Tags: ,,

PHPArch0097

This month the PDF version is FREE !

http://phparch.com/c/magazine/issue/97

There are SEVERAL articles for Developers working on the Microsoft Platform !

Installing PHP on Windows

by Hank Janssen and Pierre A. Joye

The Windows version of PHP has always lagged behind the other platforms in terms of features and stability, however, the situation has improved drastically during the last six or so months, with PHP on Windows reaching feature parity with other platforms. Developing with PHP on Windows is now easier than ever and, in some cases, has resulted in important PHP innovations. Learn how you can set up a development environment to compile and develop PHP on Windows within minutes.

Introduction to Silverlight and the HTML DOM

by Joe Stagner

This article is intended to serve as an introduction to Microsoft Silverlight for developers that are probably not .NET developers. Learn how to get started integrating your PHP apps with the Silverlight features.

Configure and Optimize PHP on Windows

by Ruslan Yakushev and Hank Janssen

It has been pretty hard in the past to figure out how to install and configure PHP on Windows. Additionally, when you did get it installed, finding information on how to optimize PHP was even harder to find. Due to the recent work done by the PHP Community and Microsoft, doing exactly that is now easier than ever.

Getting Started with the SQL Server Driver for PHP

by David Sceppa

Microsoft recently produced a PHP extension to communicate with SQL Server 2005 and 2008 databases, the SQL Server Driver for PHP. This article will cover the basic workings of this new extension, demonstrating how to connect to SQL Server, execute queries, retrieve results and manage transactions.

 

Technorati Tags: ,,

New How-Do-I Video Posted on www.asp.net

5-26-2009 9-56-41 AM

How to use the AJAX Control Toolkit to create a new custom AJAX Control Extender.

Hope you enjoy !

http://www.asp.net/learn/ajax-videos/video-7259.aspx

 

Technorati Tags: ,,,

FireAtlas – Firebug for ASP.NET Ajax !

PartialUpdateLog_part

I think probably every web developer on the planet knows about Firebug,

Laurent Chesnais has created a very cool Firefox extension for ASP.NET AJAX Developers.

It has features for ….

  • PageRequestManager events tracing
  • WebService calls tracing and inspection
  • Partial Update inspection within Firebug Net Panel
  • More to come!And… It’s FREE ![ Click HERE to Get It ! ]
    Technorati Tags: ,,,

     

  • Book – ASP.NET MVC QUICKLY from Packt Publishing!

    Packt-MVC-Quickly

    If you read my blog you know that I’m a Web Forms guy.

    ASP.NET MVC is cool, fun, HIP even, but I’m going to keep working with Web Forms.

    Still, I need to know about all the web stuff we build at Microsoft, so I’m doing some reading about ASP.NET MVC (even if only to improve my arguments with our MVC guy Stephen Walther :) )

    The KEY to this book is “Quickly”

    Without the appendices the book is 191 pages. But there is allot of information in those 191 !

    Appendix A is a reference application.

    Appendix B deals with Testing and a Mock Framework

    Appendix C is all recourses !

    One of the nice thing about Packt is that they don’t publish “definitive guide”. Packt is to publishing as is Sniper to Military.

    I highly recommend this a an ASP.NET MVC jump start.

    [ Click here to get the book at Amazon.com ]

     

    Technorati Tags: ,,

    Seven new AJAX Videos on www.asp.net/learn

    I’ve published 7 new AJAX videos.

    3 are on Setting started with VS/VWD 2008 depending on which version of the .NET Framework you are targeting.

    The rest are focused on working with the new controls in today’s update to the Microsoft AJAX Control Toolkit


    Set Up Your Development Environment for ASP.NET 3.5

     


    Set Up Your Development Environment for ASP.NET 2.0

     


    Control Extenders

     


    Color Picker

     


    Combo Box

     


    Editor Control

     


    Editor Control Custom

     

     


    Technorati Tags: microsoft asp.net ajax training

    Application Request Routing (ARR) Version 2 (B1) for IIS7

    Microsoft Application Request Routing (ARR) Version 2 for IIS7 Beta 1 has been released.

    Overview:

    ARR version 2 beta 1 is an incremental release that includes all of the features from version 1, and adds support for disk-based cache.

    More specifically, ARR version 2 beta 1 can be used to:

    · Enhance ARR version 1 scenarios with disk cache.

    · Use ARR as a cache proxy as an edge cache in CDN/ECN environment.

    Download ARRv2 beta 1 from:

    · Microsoft Application Request Routing Version 2 for IIS7 Beta 1 (x86)

    · Microsoft Application Request Routing Version 2 for IIS7 Beta 1 (x64)

    What’s new in ARRv2 beta 1:

    · Disk-based caching

    In addition to the kernel memory cache in ARR version 1, version 2 beta 1 adds support for disk-based cache.

    · Cache proxy

    Because ARR is a proxy-based HTTP request routing module, with support for disk cache, ARR can be used as a cache proxy as an edge cache.

    · Cache hierarchy management

    Define and manage relationships between cache nodes, including support for Cache Array Routing Protocol (CARP).

    · Caching while serving response

    Caching large content, such as a movie clip, may take some time. ARR version 2 beta 1 is capable of caching the content while serving the response immediately.

    · Caching compressed objects

    Disk-based cache stores compressed objects so that the objects do not have to be compressed in real time for every request.

    Documentation:

    · ARRv2 beta 1 overview

    · Install ARRv2 beta 1

    · Configure and enable disk cache in ARRv2 beta 1

    · Cache hierarchy management

    · Invalidate cache objects

      •  

    Support:

    · The support is now provided by Microsoft Support.

    · The existing ARR forum will continue to exist and the product team will continue to moderate the forum.

    Send me your questions for the ASP.NET Feature Team !!!

    As mentioned previously, I’m starting a Podcast !

    The first episode will be a Q&A of the Feature PM that owns WebForms.

    Is there a future for Web Forms ? Do I NEED to learn MVC NOW ?

    Send me your questions for the ASP.NET team by….

    Clicking HERE http://misfitgeek.com/contact/

    Or Emailing me at Joe DOT Stagner AT Microsoft DOT com

    NOTE :

    Deadline is this coming Friday at Midnight (EST)

    ONLY WebForms questions will be asked for this interview.

    Stay Tuned for an announcement of an OPEN Q&A with the ASP.NET Team !!!!!!!

    Ok – I can’t wait for your questions !!

     

    Technorati Tags: ,,

    Resources for learning programming in The Cloud.

    It’s THE CLOUD !!!

    This is “SOA” take two.

    I’ve been doing some architecture work that includes Azure and though I would share some learning resources. !

    Enjoy !

    · Webcasts – http://www.microsoft.com/events/series/azure.aspx

    · Training kit – www.microsoft.com/azure/trainingkit.mspx

    · Azure SDK – http://www.microsoft.com/azure/sdk.mspx

    · Sample projects to review – http://www.codeplex.com, search “azure”

    · Join a  Azure user group – http://www.azureusergroup.com

    - How-Do-I videos http://msdn.microsoft.com/en-us/azure/dd439432.aspx 

    LiveServices-LogoAccess Windows Live Profiles and Contacts from  PHP Apps The Azure Services Platform is continuously expanding its interoperability in a standards based approach.  Here’s another great example: Live framework is the uniform way of programming Live Services from any platform, programming language, application or device.  As a concrete example, check out a very useful “how do I” screencast  – - Access Windows Live Profiles and Contacts from PHP apps – -  by Program Manager Nishant Gupta.  He also provides a code snippet you can use to step along with the video.
    Windows_Azure_LogoUsing Logging in a Windows Azure Application Windows Azure provides a built-in framework for writing log messages from your applications. In this screencast, you’ll learn how to use the Windows Azure logging API and how to read log messages whether your application is running in the development fabric or in the cloud.
    NetServices_LogoUse the .NET Workflow Service Windows Workflow Foundation provides a platform for using managed code to defined work as composable, reusable parts. With .NET Services, you can host your workflow in the cloud and access it from anywhere. In this screencast, you’ll see the basics of taking a simple workflow and deploying it to the cloud.

     

    Technorati Tags:

    Introducing ComponentOne SharePoint Web Parts

    C1-Sharepoint-Web-Parts

    If you have ever done some SharePoint development you know that there are some unique challenges.

    ComponentOne has started building SharePoint SPECIFIC Web Parts.

    click above pr below to check them out and get the trial.

    Click [ HERE ] for more information.

    Technorati Tags:

    Get your FREE Core ASP.NET Reference Card Here !

    Get it [ HERE ]

    (Free, but Registration is Required.)

    Visual Web Developer Landing Page

    Hi Folks,

    I wanted to let you know that the Visual Web Developer Team has started a landing page specifically for VWD info.,

    You can find it here.,

    http://www.asp.net/vwd/

    ASP.NET With Visual Web Developer Video Series (First 6 On-Line)

    I’ve started updating the 2005 “Getting Started” videos.

    I’ve got many more in the works but the first 6 are live now at this URL

    http://www.asp.net/learn/videos/

    The Windows Web App Gallery

    We launched the Windows Web Application Gallery at MIX on 3/18 with 10 open source and community applications, including DotNetNuke, DasBlog, Umbraco and Subtext.

    We are now experiencing thousands of application downloads per week!

    Are you working on a community/open source application ?

    Why don’t you join the Web App Gallery?

    To get started:

    1. Review the Web App Gallery Principles to get a sense of how we keep a common baseline for user experience.

    2. Create manifest files to add to your ZIP package at using the Application Packaging Guide.

    3. Submit your application. (You’ll have to log in with a LiveID first.)

    We’ll then check out your submission to see if it follows the Web App Gallery Principles.

    Once it does, your application will be live to download in the Web App Gallery by Windows users!

    Were is a a quick FAQ based on common questions:

    Q. How do I learn more about the Web Application Gallery?

    A. Check out the Gallery itself! Or you can read more in this Introducing the Web Application Gallery whitepaper.

    Q. If my app goes into the Web Application Gallery, do Web Platform Installer users also get access to it?

    A.  Yes, if you application is accepted in the Web Application Gallery, it gets added to an ATOM feed that is consumed by Web Platform Installer as well as participating hoster control panels that integrate with the feed. You can learn more in the Introducing the Web Platform Installer whitepaper.

    Q. Can I host my project on CodePlex?

    A. Yes, our other ASP.NET Gallery partners host on CodePlex today.

    Q. Do I have to host my project on CodePlex?

    A. No. According to our Principles, you should have a public URL for the latest stable release that is supported with best effort free customer support in forums.

    Q. How long will it take to put together a Web App Gallery-enabled package?

    A. We have had partners put together the Web Deployment Tool manifests in a weekend (evenings).

    If you have any questions, you can post to the Web App Gallery forum.

    New Web Site Monitoring Service.

    When one of our sites is down, it’s a “all hands on deck” scramble.

    I use several monitoring mechanisms to let me know if there are problems on one of the sites I work on. 

    I recently added a service from APLUS Monitoring.

    Their services start at FREE !!!  – and go up to $20.95 per month. Are customizable, send email alerts (there is an SMS option) and have good reporting.

    Here’s how they describe their services.

    APlusMonitoring is a solution for your whole company. We monitor your website, server availability and performance externally from our worldwide network of monitoring locations, 24/7 and every day of the year. When your website or network fails to respond, we notify you instantly via Email, SMS/Text Messaging, RSS so that you can hit the right chord at the right time and fix them before it costs you money, customers or reputation. ”

    In addition, we keep detailed statistics about your website’s availability and response time so that you can have overall picture of your website availability and downtime. Read more about How it Works or Sign Up for a free service.

    After several weeks I continue to be impressed.

    Read [ HERE ] to see is it might be useful to you.

    UPDATE

    Receive a discount when you sign up for any paid service before April 10th 2009.

    PSSMIS – 100% off on 1st month.
    MSYR01 – 50% off on yearly payment.

    Help Shape the Future of ASP.NET

    We, The ASP.NET team, are very interested in ensuring that the “top customer pain-points” within ASP.NET are considered or acted upon in every new release.

    I’d like to ensure that you have the opportunity to connect with the product team so that you can submit your top “pain points” and so that we get a consolidated (and ideally prioritized) list of such items from a number of avenues.

    As most of my readers are avid ASP.NET Developers, I’d love to hear from you.

    Here are some areas to consider:

    - Problems understanding, as the feature area is way too complex or cumbersome

    - Problems in coding, such as way to complex, or not possible, or involves way too much code”

    - Plain bugs in the product with either no or complex workarounds

    In addition, if there are requests for new scenarios or feature sets, please pass them my way too.

    When you provide a response or idea, please give us some idea of the number of times you have encountered the issue, that might help us set priority for our investigation.

    For example, as we are in late stages for FX4, we might be able to accommodate only a few remaining requests, so a sense of priority on the issue would be required.

    We cannot guarantee that every issue will be resolved, but this represents one way that the team can be more connected with our users, and for you to help shape what gets added in new releases.

    Please send your comments, issues or any other ideas by using this link (Email Joe) and please include‘ASP.NET Customer pain-point: .. ‘ in the top of the message

    Many Thanks!

    Joe & The ASP.NET Team

    Migrating your Web Applications from IIS 6 to IIS 7

     Did you know there is an easy(er) way ???

    This article [ HERE ] explains how to use the  Web Deployment Tool [ Get it HERE ] to migrate your web applications from IIS 6 / Windows Server 2003 to IIS 7 / Windows Server 2008

    WROX Blox – Secrets of Real World ASP.NET Dynamic Data Websites

    ASP.NET Dynamic Data is one of the “Big New Things” in ASP.NET development.

    It’s a templating / scaffolding system in ASP.NET that REALLY accelerates rapid application development.

    I did a set of How-Do-I videos which you can find here – http://www.asp.net/dynamicdata/

    WROX has come out with a “Wrox Blox” e-book on Dynamic Data.

    I’ve read it and it’s definitely worth the$6.99

    Click [ HERE ] to check it out or buy it !

    MVC Book Download from "The Gu"

    Scott Guthrie has a free 185 page book chapter on ASP.NET MVC that you can download for free.

    Info on the book can be found at : http://tinyurl.com/aspnetmvc

    The chapter is available directly at : http://aspnetmvcbook.s3.amazonaws.com/aspnetmvc-nerdinner_v1.pdf

    It builds an application from scratch and introduces all of the concepts involved with ASP.NET MVC along the way.

    COOL !

    LINQ-TO-Twitter ?

    Mehfuz Hossain (a Microsoft MVP) has been working on [ Creating Custom LINQ Providers ] and has built a [ LINQ-to-Twitter ] provider.

    Man our MVP’s are the BEST !!

    Email Reporter: VSTS 2008 Load Test Plug-in

    The ASP.NET Community Rocks !!!!

    ASP.NET MVP Mohammad Ashraful Alam just released a cool Plug-In for VSTS …….

    An “Email Reporter” for VSTS…..

    “Email Reporter: VSTS 2008 Load Test Plug-in” enables users to send the load test reports to one or more pre-configured email addresses automatically, once a VSTS Load Test is completed. This open-source load test plug-in also provides supports for customization by which you can customize the reported performance data.

    Check it out here…..

    http://code.msdn.microsoft.com/erep

    .NET Rocks Interview on the Application Architecture Guide 2.0

    If you read my blog by now you know I’m a big fan of the Microsoft Patterns and Practices Team !!

    Well, my buddy Carl Franklin just did a .NET Rocks episode on the new Application Guide 2.0

    Check out .NET Rocks show #426, Rob Boucher on Application Architecture Guidance

    It’s an in-depth interview with Rob Boucher from our Microsoft patterns & practices Application Architecture Guide 2.0 project

    It’s a behind the scenes look at the making of the guide and you get to know Rob along the way.  There’s a lot of insight about the structure of the guide, as well as the approach we used in the guide.  There’s also a lot of inside information on the design intentions and usage scenarios. 

    It ROCKS !

    Evolutility Open Source ASP.NET Framework

    Evolutility is an open source framework for CRUD (Create, Read, Update, Delete) web applications running on Microsoft ASP.net and SQL Server

    http://www.evolutility.org/

    The Web Service Software Factory: Modeling Edition

    I’ve been playing with yet another goodie bundle from the P&P folks.

    Did you know about this ???

    The Web Service Software Factory: Modeling Edition (also known as the Service Factory) is an integrated collection of resources designed to help you quickly and consistently build Web services that adhere to well-known architecture and design patterns. These resources consist of patterns and architecture topics in the form of written guidance and models with code generation in the form of tools integrated with Visual Studio 2008.

    http://msdn.microsoft.com/en-us/library/bb931187.aspx

    Announcing The Microsoft Web Platform Installer

    The Microsoft Web Platform Installer is a free tool that makes it simple to download and install the latest components of the Microsoft Web Platform, including Internet Information Services (IIS) 6.0 and 7.0, SQL Server 2008 Express, .NET Framework 3.5 SP1 and Visual Web Developer 2008 Express SP1. The Web Platform Installer offers a single installer to help you obtain the software you need to build and run a complete Web solution on the Microsoft Web platform, whether you are using Windows XP, Windows Server 2003, Windows Vista, or Windows Server 2008. In addition, the Web Platform Installer checks online to ensure the most current versions and new additions to the Microsoft Web Platform are downloaded.

    [ Click HERE to get it. ]

    ComponentOne Silverlight WebParts for SharePoint

    ComponentOne announced the initial CTP release of our “ComponentOne WebParts for SharePoint” product, available for discovery and download at http://labs.componentone.com/WebParts/.

    It’s ht be interesting to see their direction on melding Silverlight and SharePoint

    From their web site…..

     

    ComponentOne WebParts leverage the power of Microsoft’s Silverlight technology for superior performance, styling, animation, and interactivity. Version 1 of ComponentOne WebParts for SharePoint includes three feature-packed web parts:

    • ComponentOne DataGrid™ for SharePoint
    • ComponentOne Chart™ for SharePoint
    • ComponentOne Maps™ for SharePoint

    These web parts access both SharePoint lists and SQL Server data. They are easily configurable by administrators and, if permissible, by end users alike.

    DotNetNuke Moves to Microsoft Codeplex !

     Peter Galli on Port 25 fills us in that DotNetNuke has moved to Microsoft CodePlex !

    It’s great to see the growing vibrancy to CodePlex and the Open Source ASP.NET Community.

    Check it out here: http://www.codeplex.com/dotnetnuke

    If I ever get time to write code again I wanna to qa CodePlex project !

    ASP.NET MVC Design Gallery and Design Competition

    For some time now we’ve been working on a new option for ASP.NET Developers. ASP.NET MVC !

    Phil Haak and the crew have been furiously at work on ASP.NET MVC and Stephen Walter (with great work from Phil, Tom, Jay, Jay-E, Rich, Zac, and JM) has been building a gallery to show off great MVC designs.

    It’s NOW LIVE HERE (http://www.asp.net/MVC/Gallery/)

    To kick things off WE’RE HAVING A CONTEST !!!

    You can get all the details and submit your design until January 31st HERE (http://www.asp.net/MVC/Gallery/Competition/)

    Murach’s ASP.NET 3.5 Web Programming with C# 2008

    At the top of this book it says “TRANING AND REFERENCE” in capital letters.

    That sums it up :) 1000 pages of soup to nuts learning about developing ASP.NET applications in C#, updated for ASP.NET 3.5 and C# / Visual Studio 2008.

    In addition to all the concepts for ASP.NET, C#, OOP, IIS, etc, the book has sections on Data Access (AND LINQ), AJAX, Listview & Datapager, CSS and more.

    Murach’s makes great textbook style learning material. As I’ve said before. if I were teaching a college class on the subject, this would be on the short list for the textbook of choice.

    [ Click HERE to check it out on AMAZON.com ]

    Announcing the Web Platform Installer Release Candidate!

    The Web Platform Installer (Web PI) is a simple tool that installs Microsoft’s entire Web Platform, including IIS7, Visual Web Developer 2008 Express Edition, SQL Server 2008 Express Edition and the .NET Framework. Using the Web Platform Installer’s user interface, you can choose to install either specific products or the entire Microsoft Web Platform onto your computer. The Web PI also helps keep your products up to date by always offering the latest additions to the Web Platform. 

    New Updates! Now supporting Windows XP and Windows Server 2003, Web PI makes it easy to install and stay up-to-date with the Microsoft Web Platform.  This updated release lets you install ASP.NET MVC, Visual Studio Tools for Silverlight, and much more!

    [ CLICK HERE to get the details. ]

    NEW Web Application and Platform Installers from Microsoft.com/web.

    Do you know about Microsoft.com/web ?

    Wanna get up and running quickly ? 

    Wanna auto install free ASP.NET or PHP Applications on your Windows Stack.

    Then this is some real coolness for YOU !

    Previews are below.

    Hop over to http://www.microsoft.com/web to download and be sure to check out the other cool news and resources !!!\

     

    Microsoft Web Platform Installer

    The Web Platform Installer Beta (Web PI) provides a single, free package for installing and configuring Microsoft’s entire Web Platform, including IIS7, Visual Web Developer 2008 Express Edition, SQL Server 2008 Express Edition and the .NET Framework. Using the Web Platform Installer’s simple user interface, you can select specific components or more…


    Microsoft Web Application Installer

    The Web Application Installer (Web AI) is the smoothest way to install the freely available PHP and ASP.NET applications on the IIS Web Server. Simply select the applications you want, enter your personal configuration, and click a button. Web AI even checks that all the database and framework components more…

    Flickr Xplorer – A Cool ASP.NET MVC Example !

    Mehfuz Hossain has created a cool open source application based on ASP.NET MVC

    The CodePlex project can be found HERE !

    You can use the application LIVE – HERE !

    The Digital Blackbelt Webcast Series is BACK !

    I’ve been working hard to get more security related work back into my schedule.

    And so….. I’m starting a new “season” of the Digital Blackbelt webcast series.

    If we get enough interest I’ll do some give-a-ways and such !

    SIGN UP NOW !!!! Here are the first 3 dates !

    11/3/2008; 11:00 AM (PST)

    Convincing Management: The Business Case for Adding Security to the Development Life Cycle

    [ Click HERE to Register ]

    11/10/2008; 11:00 AM (PST)

    Security Development Lifecycle: Building an Intentionally Secure Development Process

    [ Click HERE to Register ]

    11/24/2008; 11:00 AM (PST)

    Threat Modeling for Software Developers

    [ Click HERE to Register ]

    Another example of the RICH ASP.NET 3rd Party Controls Market – Web.UI 2008.2

    One of the very BEST parts of my job is the opportunity to use many of the great developer tools that are out there in the wild !

    Like most of the big controls venders, the kind folks at Component Art keep me up to date with the Web.UI suite !

    I’m hoping to start blogging my walk through Impressions of ALL the tools I get to use, but often I only get to writing a blog post when the company sends me an email with an update !

    I got this yesterday from Component Art.

    ComponentArt is pleased to announce the immediate availability of Web.UI 2008.2. The latest release of the industry’s best performing ASP.NET AJAX user interface framework features three new controls, expanded capabilities of the Grid control as well as accessible output and Section 508 compliance for all Web.UI controls.

    Look at how sexy these UI components are !!!  I love the AJAX support and the increased focus on performance, which is really necessary as folks add more and more ‘Ajaxy” functionality to their applications.

    You can check out the live demos here http://www.componentart.com/webui/demos/

    Dynamic Data with Stored Procedures

    So there is this very smart guy on the ASP.NET team named Scott Hunter who is one of the guys working on Dynamic Data !

    He has just added a sample of using Dynamic Data with Stored Procedures to the Dynamic Data Samples on CodePlex.

    Click [ HERE ] for the Sample Project home page.

    Click [ HERE ] for a forums discussion on Dynamic Data with Stored Procedures.

    Murach’s ASP.NET Web Programming with VB.NET

    Murach’s ASP.NET 3.5 Web Programming with VB 2008: Anne Boehm: Books

    ISBN: 1890774472
    ISBN-13: 9781890774479

     

    I love this book.

    If I were going to teach a course on ASP.NET Development with VB – THIS is the book I would teach it from !

    Get a a copy !

    Murach’s Description

    There is no faster or better way to learn ASP.NET web programming using Microsoft’s Visual Studio .NET than to use “Murach’s ASP.NET web programming with VB.NET.” To get you off to a fast start, the first 5 chapters show you how to use Microsoft Visual Studio to design, code, and test multi-page web applications that use view state, session state, cookies, database data, and code-behind files.

    From there, you learn even faster as you master the core professional skills like HTML, server controls, validation controls, state management, and user controls. Then, you learn how to use the best ADO.NET features for working with a database in a web application including: connection pooling, data commands, parameterized queries, caching, data views, command builders, and the Repeater, DataList, and DataGrid controls.

    Last, you learn how to apply the finishing touches to a web application: security, web services, custom server controls, reports generated by Crystal Reports, email, and deployment. “No other book teaches so much, so fast, or so thoroughly.”

    Amazon Product Description

    “This book is by far the best computer programming book I have ever bought. You can go into my upstairs closet and find 20-30 books that I have purchased since the days of VB6…. All together, they could not add up to as much information as you have given me in the first 11 chapters of this book.” (A developer’s comment on the previous edition of Murach’s ASP.NET)
    Already know how to code Visual Basic 2008 desktop applications? Then, you’re ready to master web programming with the 3.5 edition of this best-selling ASP.NET book from Murach Books.

    It covers the 3.5 features that provide new functionality…like the ListView and DataPager data controls, LINQ data sources, new CSS-related tools, and ASP.NET AJAX…while it teaches you how to develop web applications from scratch. And it does that using all the same features that have made earlier editions such favorites among professional developers:

    It’s concise, practical, and crystal-clear in telling you what you need to know

    It shows you how to get the most from Visual Studio 2008 as you code, test, debug, and deploy ASP.NET web applications

    It gives you a 7-chapter section on database programming…2 more chapters than in the previous edition because .NET continues to deliver new, powerful tools for this critical component of business applications

    It gives you solid training in the essential skills that you’ll use every day, including data validation…state management…improving the user experience with easy site navigation and a standard look and feel…boosting user response time with ASP.NET AJAX…handling security…developing reusable controls…working with database data using SQL, object, and LINQ data sources…and more

    It gives you real-world application examples that guide you in applying what you’re learning as you develop your own websites (you can download the applications for free from the Murach website)

    Its paired pages presentation makes for fast reading, instant reinforcement, and time-saving reference (to see how the paired pages work, you can download free chapters from the Murach website)

    ASP.NET AJAX 4.0 CodePlex Preview 1 available

    We’re very happy to announce that the first preview for the new Ajax features in ASP.NET just went live.

    For more information check out the Roadmap.

    This preview contains preview implementations for the following features:

    • Client-side template rendering
    • Declarative instantiation of behaviors and controls
    • DataView control
    • Markup extensions
    • Bindings

    I’ll work on videos to cover the new features !

    As usual, all feedback is very welcome.

    http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=15511

    Will ASP.NET MVC be the main web UI platform for ASP.NET?

    Microsoft folks are very enthusiastic ! We love to dig in to new technology and show off the cool work that we do and this has been VERY true of ASP.NET MVC.

    Unfortunately, sometimes our zeal get’s misinterpreted.

    I’m getting lots of questions about the future of ASP.NET development as it pertains to MVC and WebForms – and folks are concerned and worried.

    Today I got an email from a former Microsoftie asking these common questions so I thought I would answer them here.

    1.) Will ASP.NET MVC will be the main web platform for ASP.NET?

    NO !

    MVC is an option. It will NOT replace WebForms. WebForms will continue to evolve and be the PRIMARY UI developers mechanism for ASP.NET. MVC will be great for a subset of ASP.NET applications and developers.The point is, ASP.NET developers will have a great available CHOICE.

    Personally – I will continue to use WebForms and will likely not use MVC much if at all. 

    2.) Will WebForms continue to be expanded/supported ?

    YES! YES! YES !

    In fact, this fall I’ll be focusing on publishing videos and such on NEW WebForms Features and usage scenarios.

    3.) Which JavaScript framework is recommended to be used with ASP.NET MVC (ASP.NET AJAX, jQuery, etc.)?

    Microsoft supports our own AJAX Client Libraries, but I regularly use jQuery and other independent libraries. The Microsoft libraries are integration friendly with any JavaScript library that uses some king of Name-Spacing mechanism to avoid naming collisions.

    4.) How well ASP.NET AJAX will be supported with ASP.NET MVC?

    Who knows? ASP.NET AJAX is built around the page postback model so the server side stuff is decidedly WebForms but the client stuff is happy anywhere.

    Check outthis post by Nikhil where he adds some basic AJAX stuff to an MVC application.

    http://www.nikhilk.net/Ajax-MVC.aspx

    5.) Will ASP.NET AJAX and Ajax Control Toolkit will be expanded/supported?

    YES !

    Simply – YES !

    LONG LIVE WEB FORMS !

    Advanced ASP.NET AJAX Server Controls

    It’s finally hitting the street – "Advanced ASP.NET Ajax Server Controls"

    I had the pleasure to be a technical reviewer on this book during the writing process and am really excited about it’s release.

    This book if one of the few that dive deep into the framework, its architecture and extensibility, and address the power-user/developer scenarios and it does it from a controls perspective. It’s a big undertaking but Adam and Joel have done a great job.

    As Nikhil said "If you’re building applications in Ajax today, and want to take that to the next level, you’ll want to look into the platform deeper beyond the out-of-the-box features i.e. its extensibility. You’ll specifically want to build reusable components and controls, on both the server and on the client. Check out this book on more details like "the client script framework", "the script application object", "localization" and "the control toolkit" amongst many other relevant topics".

    [ Get a copy HERE ]

    Why would you write your own WYSIWYG editor?

    I recently had an email exchange with someone asking me about how to approach writing their own WYSIWYG editor control for web applications.

    Perhaps an interesting academic exorcize, or maybe he has some very specific application  but it got me thinking about how many implementations there are out there already !

    While searching I found this great list which is lifted entirely from Mike Pope [ Click HERE to Read at Mike's Blog ] – THANKS MIKE !

    Rich Editor Controls that you can use with ASP.NET

    HTML Editors
    As near as I can tell, all of these work in-browser and produce HTML or XHTML.

    Word Processing, RTF, PDF, and more
    These variously support other formats, notably non-HTML (e.g. RTF) and sometimes PDF.

    Other/Not Sure
    I’m not sure how exactly these fit into the picture; they’re listed at least in one location as being ASP.NET editors.

    • Community Editor (BigByte). Desktop editing, it says; possibly not in-page HTML editing? Appears to be free.
    • DevEdit NX (Interspire). Not 100% clear that it supports ASP.NET.

    More Information

    • A similar list is available at 123aspx.com.
    • Daniel Walzenbach published a list as well in December 2007. With pictures! :-)
    • Scott Mitchell has an article on using FreeTextBox.
    • Building a WYSIWYG HTML Editor” A two-part article by Mitchell Harper. I’m pretty certain that this is for Internet Explorer only, tho.

    .NET Coding Guidelines

    BradA referred me to some Internal Coding Guidelines hat I thought I’d share…

     

    Table of Contents

    1. Introduction………………………………………………………………………………………………………………………… 1

    2. Style Guidelines…………………………………………………………………………………………………………………… 2

    2.1 Tabs & Indenting……………………………………………………………………………………………………………….. 2

    2.2 Bracing…………………………………………………………………………………………………………………………….. 2

    2.3 Commenting………………………………………………………………………………………………………………………. 2

    2.3.1 Documentation Comments………………………………………………………………………………………………. 2

    2.3.2 Comment Style…………………………………………………………………………………………………………….. 3

    2.4 Spacing…………………………………………………………………………………………………………………………….. 3

    2.5 Naming…………………………………………………………………………………………………………………………….. 4

    2.6 Naming Conventions……………………………………………………………………………………………………………. 4

    2.6.1 Interop Classes…………………………………………………………………………………………………………….. 4

    2.7 File Organization………………………………………………………………………………………………………………… 5

    1. Introduction

    First, read the .NET Framework Design Guidelines. Almost all naming conventions, casing rules, etc., are spelled out in this document. Unlike the Design Guidelines document, you should treat this document as a set of suggested guidelines. These generally do not effect the customer view so they are not required.

    2. Style Guidelines

    2.1 Tabs & Indenting

    Tab characters (\0×09) should not be used in code. All indentation should be done with 4 space characters.

    2.2 Bracing

    Open braces should always be at the beginning of the line after the statement that begins the block. Contents of the brace should be indented by 4 spaces. For example:

    if (someExpression)
    {
    DoSomething();
    }
    else
    {
    DoSomethingElse();
    }

    “case” statements should be indented from the switch statement like this:

    switch (someExpression)
    {

    case 0:
    DoSomething();
    break;

    case 1:
    DoSomethingElse();
    break;

    case 2:
    {
    int n = 1;
    DoAnotherThing(n);
    }
    break;
    }

    Braces should never be considered optional. Even for single statement blocks, you should always use braces. This increases code readability and maintainability.

    for (int i=0; i<100; i++) { DoSomething(i); }

    2.3 Single line statements

    Single line statements can have braces that begin and end on the same line.

    public class Foo
    {
    int bar;

    public int Bar
    {
    get { return bar; }
    set { bar = value; }
    }

    }

    It is suggested that all control structures (if, while, for, etc.) use braces, but it is not required.

    2.4 Commenting

    Comments should be used to describe intention, algorithmic overview, and/or logical flow. It would be ideal, if from reading the comments alone, someone other than the author could understand a function’s intended behavior and general operation. While there are no minimum comment requirements and certainly some very small routines need no commenting at all, it is hoped that most routines will have comments reflecting the programmer’s intent and approach.

    2.4.1 Copyright notice

    Each file should start with a copyright notice. To avoid errors in doc comment builds, you don’t want to use triple-slash doc comments, but using XML makes the comments easy to replace in the future. Final text will vary by product (you should contact legal for the exact text), but should be similar to:

    //———————————————————————–
    // <copyright file="ContainerControl.cs" company="Microsoft">
    // Copyright (c) Microsoft Corporation. All rights reserved.
    // </copyright>
    //———————————————————————–

    2.4.2 Documentation Comments

    All methods should use XML doc comments. For internal dev comments, the <devdoc> tag should be used.

    public class Foo
    {

    /// <summary>Public stuff about the method</summary>
    /// <param name=”bar”>What a neat parameter!</param>
    /// <devdoc>Cool internal stuff!</devdoc>
    ///
    public void MyMethod(int bar) { … }

    }

    However, it is common that you would want to move the XML documentation to an external file – for that, use the <include> tag.

    public class Foo
    {

    /// <include file=’doc\Foo.uex’ path=’docs/doc[@for="Foo.MyMethod"]/*’ />
    ///
    public void MyMethod(int bar) { … }

    }

    UNDONE§ there is a big doc with all the comment tags we should be using… where is that?

    2.4.3 Comment Style

    The // (two slashes) style of comment tags should be used in most situations. Where ever possible, place comments above the code instead of beside it. Here are some examples:

    // This is required for WebClient to work through the proxy
    GlobalProxySelection.Select = new WebProxy("http://itgproxy");

    // Create object to access Internet resources
    //
    WebClient myClient = new WebClient();

    Comments can be placed at the end of a line when space allows:

    public class SomethingUseful
    {
    private int itemHash; // instance member
    private static bool hasDoneSomething; // static member
    }

    2.5 Spacing

    Spaces improve readability by decreasing code density. Here are some guidelines for the use of space characters within code:

    • Do use a single space after a comma between function arguments.
      Right: Console.In.Read(myChar, 0, 1);
      Wrong: Console.In.Read(myChar,0,1);
    • Do not use a space after the parenthesis and function arguments
      Right: CreateFoo(myChar, 0, 1)
      Wrong: CreateFoo( myChar, 0, 1 )
    • Do not use spaces between a function name and parenthesis.
      Right: CreateFoo()
      Wrong: CreateFoo ()
    • Do not use spaces inside brackets.
      Right: x = dataArray[index];
      Wrong: x = dataArray[ index ];
    • Do use a single space before flow control statements
      Right: while (x == y)
      Wrong: while(x==y)
    • Do use a single space before and after comparison operators
      Right: if (x == y)
      Wrong: if (x==y)

    2.6 Naming

    Follow all .NET Framework Design Guidelines for both internal and external members. Highlights of these include:

    • Do not use Hungarian notation
    • Do not use a prefix for member variables (_, m_, s_, etc.). If you want to distinguish between local and member variables you should use “this.” in C# and “Me.” in VB.NET.
    • Do use camelCasing for member variables
    • Do use camelCasing for parameters
    • Do use camelCasing for local variables
    • Do use PascalCasing for function, property, event, and class names
    • Do prefix interfaces names with “I”
    • Do not prefix enums, classes, or delegates with any letter

    The reasons to extend the public rules (no Hungarian, no prefix for member variables, etc.) is to produce a consistent source code appearance. In addition a goal is to have clean readable source. Code legibility should be a primary goal.

    2.7 Naming Conventions

    2.7.1 Interop Classes

    Classes that are there for interop wrappers (DllImport statements) should follow the naming convention below:

    • NativeMethods – No suppress unmanaged code attribute, these are methods that can be used anywhere because a stack walk will be performed.
    • UnsafeNativeMethods – Has suppress unmanaged code attribute. These methods are potentially dangerous and any caller of these methods must do a full security review to ensure that the usage is safe and protected as no stack walk will be performed.
    • SafeNativeMethods – Has suppress unmanaged code attribute. These methods are safe and can be used fairly safely and the caller isn’t needed to do full security reviews even though no stack walk will be performed.

    class NativeMethods
    {
    private NativeMethods() {}

    [DllImport(“user32”)]
    internal static extern void FormatHardDrive(string driveName);
    }

    [SuppressUnmanagedCode]
    class UnsafeNativeMethods
    {
    private UnsafeNativeMethods() {}

    [DllImport(“user32”)]
    internal static extern void CreateFile(string fileName);
    }

    [SuppressUnmanagedCode]
    class SafeNativeMethods
    {
    private SafeNativeMethods() {}

    [DllImport(“user32”)]
    internal static extern void MessageBox(string text);
    }

    All interop classes must be private, and all methods must be internal. In addition a private constructor should be provided to prevent instantiation.

    2.8 File Organization

    • Source files should contain only one public type, although multiple internal classes are allowed
    • Source files should be given the name of the public class in the file
    • Directory names should follow the namespace for the class

    For example, I would expect to find the public class “System.Windows.Forms.Control” in “System\Windows\Forms\Control.cs”…

    • Classes member should be alphabetized, and grouped into sections (Fields, Constructors, Properties, Events, Methods, Private interface implementations, Nested types)
    • Using statements should be inside the namespace declaration.

    namespace MyNamespace
    {

    using System;

    public class MyClass : IFoo
    {

    // fields
    int foo;

    // constructors
    public MyClass() { … }

    // properties
    public int Foo { get { … } set { … } }

    // events
    public event EventHandler FooChanged { add { … } remove { … } }

    // methods
    void DoSomething() { … }
    void FindSomethind() { … }

    //private interface implementations
    void IFoo.DoSomething() { DoSomething(); }

    // nested types
    class NestedType { … }

    }

    }

    SplendedCRM – The Open Source ASP.NET CRM Product gets a new version.

    Silverlight, AJAX and PDF Invoices Cement SplendidCRM as the Ideal CRM Platform for Companies that have Standardized on the Microsoft Technology Stack

    RALEIGH, N.C.–(BUSINESS WIRE)–SplendidCRM Software, Inc., a pioneering provider of Microsoft-centric Customer Relationship Management (CRM) solutions for open-source use, today announced the launch of Version 2.1 of its flagship platform SplendidCRM. The new Silverlight graphs provide SplendidCRM developers with unprecedented ability to create and customize graphs. Extended AJAX support provides the CRM user with a more natural experience.

    “Integration of the latest Microsoft technologies into SplendidCRM continue to make it the ideal back-office platform,” said Paul Rony, President of SplendidCRM. “Our decision to standardize on the Microsoft Report Definition Language (RDL) allowed us to create an Invoice using Microsoft’s Report Designer and import it into SplendidCRM. The end result is the ability to generate PDF invoices at the click of a button.”

    New Features

    In addition to the technology enhancements, the SplendidCRM query system has been optimized to focus on retrieving active fields. This optimization dramatically increases the performance of SplendidCRM when managing tables with more than 100,000 records.

    User Interface Enhancements

    Credit Card management and processing using the popular .netCHARGE component (licensed separately) allows SplendidCRM to become your primary order-management system.

    PayPal Instant Payment Notification is now supported, thereby ensuring that sales are automatically and instantly tracked by the CRM.

    Built-in Language Support has been added for 24 languages, including English, French, Italian, German, Spanish, Japanese, Arabic, Bulgarian, Czech, Danish, Greek, Finnish, Hindi, Croatian, Korean, Norwegian, Dutch, Polish, Portuguese, Romanian, Russian, Swedish, Simplified Chinese and Traditional Chinese.

    Incorporation of AJAX into sub panels enables the list to be sorted and paginated without the full page refresh.

    Developer Enhancements

    SplendidCRM continues to be the ideal platform for .NET back-office applications with the deep penetration of Microsoft technologies. When put together, these technologies help developers achieve Rapid Application Development (RAD).

    PDF Generation of Invoices, Orders and Quotes is enabled via a combination of Dynamic Buttons, imported RDL reports and the Microsoft Report View.

    Dynamic Buttons further extend the data-driven foundation of SplendidCRM. By dynamically rendering the buttons, you get to add field data to the buttons. This is important because it allows you to add a Print Invoice button that references a specific report.

    Silverlight graphs replace the old flash-based graphs and allow you to customize the XAML output in the same way that you customize an ASP.NET page to produce HTML. This approach also allows you to embed more business logic into a graph.

    Regular Expression Validation of the EditViews give your users immediate feedback when they type an invalid email address or phone number

    Migration to ASP.NET themes and skins simplifies the code and makes it easier for developers to create their own themes and skins.

    Administration

    SplendidCRM introduces new administrative features for tracking usage and problems.

    Persistent System Log helps you track the overall health of the system. Administrators can view warnings and errors with sufficient information to help developers pinpoint the problem.

    User Login tracking helps administrators track the usage of the system.

    In-place migration of a SugarCRM MS SQL database dramatically reduces the effort to migrate to SplendidCRM.

    To see this new functionality, please visit http://demo.splendidcrm.com. To sign-up for a free trail of SplendidCRM 2.1, please visit http://eval.splendidcrm.com.

    About SplendidCRM Software, Inc.

    Founded in 2005, SplendidCRM Software provides a Microsoft-centric open-source Customer Relationship Management (CRM) application that, unlike most open-source solutions built for a Linux environment, enables users to leverage their existing Microsoft infrastructure. The company is located in the Research Triangle of Raleigh, North Carolina, and is privately held.

    To learn more about SplendidCRM, email sales@splendidcrm.com or visit www.splendidcrm.com.

    Are you Powered by ASP.NET 3.5 – Get Your Button !

    Powered By ASP.NET 3.5 Powered By ASP.NET 3.5 Powered By ASP.NET 3.5

    Is your site powered by ASP.NET 3.5 ??

    Grab a button and show your pride !

    http://www.asp.net/images/pow_by_aspnet3.5a.png

    http://www.asp.net/images/pow_by_aspnet3.5b.png

    http://www.asp.net/images/pow_by_aspnet3.5c.png

    Microsoft Web Deployment Tool Beta

    The IIS team has released the Beta 1 (Go Live) release of the Microsoft Web Deployment Tool! The tool provides deployment and migration support for IIS 6.0 and 7.0. It incorporates many features that enable web server administrators to deploy, sync and migrate sites, including configuration, content, SSL certificates and other types of content associated with a Web server.

    This tool can be used on Windows Server 2008 and IIS 7.0 as well as Windows Server 2003 and IIS 6.0. Please note that this is a Beta release, support is available on the forums.

    How to Get Started  

    Download the x86 version: http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1602

    Download the x64 version: http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1603

    Read the walkthroughs: http://go.microsoft.com/?linkid=8100895

    Web Deployment Tool forum: http://forums.iis.net/1144.aspx

    Web Deployment Team blog: http://blogs.iis.net/msdeploy/

    Features

    • PowerShell Support - We have PowerShell cmdlets so that you can integrate MS Deploy commands with PowerShell directly.
    • Enhanced Dependency Checking – We have IIS7 dependency information listed, plus the ability to see where a dependency is being triggered from. For example, if you have a dependency on Windows Authentication, you can now determine where this is set in the configuration.
    • Detailed Help File - We have a Help chm file included in the tool so that you can browse through all the functionality and flexibility offered by the tool, instead of looking through online walkthroughs.

    BOOK: ASP.NET Data Presentation Controls

    Here is a GREAT quick read on ASP.NET Data Controls for you.

    PACKT is not one of the “big” publishing companies, which can be a good thing because that often publish books on specific topics that are left un-covered by the usual suspects. One of their slogans is “Community Experience Distilled” which I think really nails them.

    This book is spans about 240 pages exclusivly on ASP.NET Data Presentation controls.

    It covers things like …

    • Data Binding
    • Repeater Control
    • List Controls
    • Data Grid
    • Grid View
    • Form View
    • Detail View

    Bets of all it contains coverage of both 2.0 and 3.5 concepts like LINQ, the new 3.5 ListView & DataPager controls and using VS 2008.

    Click on the book image above to check it out at Amazon.com

    BOOK: Advanced ASP.NET AJAX Server Controls: For .NET 3.5

    I frequently am asked to server as a technical reviewer on development books. Time doesn’t permit me to always say yes but I try to make time to agree to do the more interesting titles.

    This book is one I said yes to. Adam and Joel have done a great job of exposing this detailed subject.

    Controls are such a powerful re-use mechanism and so under covered.

    The book is due for release on July 15th and you can save 5% with an Amazon.com preorder.

    [ Click HERE for the book on Amazon.com ]

    Multiple UpdatePanels – Who caused the update ?

    Does your client code need to know what control caused your update panels to update or which of several UpdatePanels contained the triggering control ? Try this…. (Or do the same thing with addbeginRequest();

        1 <script type=”text/javascript”>
        2 <!–
        3 var prm = Sys.WebForms.PageRequestManager.getInstance();
        4
        5 prm.add_endRequest(EndRequest);
        7 function EndRequest(sender,args)
        8     {
        9     alert(sender._postBackSettings.panelID + ” -> “ + sender._postBackSettings.sourceElement.id);
       10     }
       11  –>
       12 </script>

     Note that “id” contains the id of the CONTROL that caused the postback. panelId contains a string that appends the event trigger with the UpdatePanel name.   Note that if the update was caused by an event configured in the Triggers Collection or updated explicitly in JavaScript, the “Control” name will be the UpdatePanel.

    2 New AJAX How-Do-I Videos Now Available

    #71 | How To Dynamically Change CSS Using the ASP.NET AJAX UpdatePanel

    #72 | How To Dynamically Add Controls to a Web Page (and not have them disappear when you post-back)

    AJAX UpdatePanel – "Statefull" Control Update Trigger

    I get an obscene amount of email. Since I’ve been working with the Developer Community at Microsoft for 7 years, my email address has been spread around a bit. I get about 1000 email a day. Very often from developers who what me to write code for them :)

    I generally don’t have time to do that, but sometimes I get an email from someone why has really tried to solve a problem that should be simple, but whose answer is not always as obvious as the problem would lead you to believe.

    This week a Developer emailed me about updating an UpdatePanel.

    One of the true strengths of ASP.NET is the ability to take several different approaches to writing applications based on your needs and preferred development style.

    Though I think the UpdatePanel control is AWESOME, my personal preference for AJAX style programming leads me to write more client side code and communicate with the server via JavaScript enabled web service calls.

    The problem was, the developer was using the UpdatePanel and, due to functionality in the business layer, he needed to prevent the user from click a submit button twice in a row. Meaning, when the user clicks the button that caused the UpdatePanel to update, he needed that buttonto be disabled until the UpdatePanel’s refresh was complete.

    So, the UpdatePanel definition looks like this.  

       22         <div>

       23             <asp:UpdatePanel ID=”UpdatePanel1″ runat=”server”>

       24                 <ContentTemplate>

       25                     <asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>

       26                     <br />

       27                     <br />

       28                     <asp:Label ID=”Label1″ runat=”server” Text=”Label” Width=”622px”></asp:Label><br />

       29                     <br />

       30                 </ContentTemplate>

       31             </asp:UpdatePanel>

       32         </div>

       33         <br />

       34         <input id=”SubButton” style=”width: 618px” type=”button” value=”Call UpdatePanel Method” onclick=”return SubButton_onclick()” />

       35         <br />

       36         <br />

     

    Note that the HTML button control “SubButton” is outside the UpdatePanel and is not defined as a Trigger to the UpdatePanel.

     

    In order to turn the Button off and get the UpdatePanel to update, we’re going to do it all in JavaScript.

    If you use an ASP.NET Button control and disable the Button with an OnClientClick event handler, that code fires first and the postback never occurs.

     

    Our JavaScript “SubButton_onclick()” function looks like this.

     

        4 <script type=”text/javascript”>

        5 <!–

        6 function SubButton_onclick()

        7 {

        8     var prm = Sys.WebForms.PageRequestManager.getInstance();

        9     var mybutton = document.getElementById(‘SubButton’)

       10     mybutton.disabled = true;

       11     prm._doPostBack(‘UpdatePanel1′, );

       12 }

       13 // –>

       14 </script>

     

    Hopefully the code is self explanatory. 

     

    The Button is disabled and the UpdatePanel postback is triggered.

     

    But…. How do we know when the update is complete so we can re-enable the Button.

     

     

       37 <script type=”text/javascript”>

       38 <!–

       39 var prm = Sys.WebForms.PageRequestManager.getInstance();

       40 

       41 prm.add_endRequest(EndRequest);

       42 

       43 function EndRequest(sender,args)

       44     {

       45     var mybutton = document.getElementById(‘SubButton’);              

       46     mybutton.disabled = false;

       47     }

       48  –>

       49 </script>

     

    Luckily, the PageRequestManager is throughly evented. :)  

     

    We just add an “EndRequest” event handler and have it re-enable the Button.

     

    Pretty simple after you see the solution :)

     

    [ Download the code HERE. ]

     

    ASP.NET Dynamic Data – Don’t skip over it!

    Today Scott Guthrie posted about the new preview availability of ASP.NET Dynamic Data. [Click HERE to read his post.]

    I know, the pace of new releases makes it hard to keep up and you need to pick and choose which things you invest your time in!

    When you hear about ASP.NET 3.5 “Dynamic Data”, you often see a screen-shot like the one Scott blogged.

    Resist the temptation to say “Yea, another datagrid control”.

    This is one of the most exciting new ASP.NET Technologies.

    I’ll be presenting on ASP.NET 3.5 Dynamic Data at ASP.NET Connections in a couple of weeks.

    After that – would you all like some How-D-I videos on Dynamic Data ????

    Making nested ASP.NET applications work !

    Have you ever tried to set up a web site and use 2 popular ASP.NET applications ?

    Did you get THIS ?

    I did.

    I set up BlogEngine.net in c:\inetpub\wwwroot – it worked fine !

    Then I set up ScrewTurnWiki in c:\inetpub\wwwroot\wiki.

    Now, ScrewTurnWiki is really simple to install and it’s always worked for me before but this install failed (though as you’ll see the problem is ASP.MET and the applications.)

    The error messages that I was getting when trying to load the wiki were about not being able to resolve a BlogEngine.net assembly !

    The problem is this……

    ASP.NET applications have a distinct and complete configuration hierarchy. This is very useful if you are taking advantage of it, but can be a real pain if you are not.

    The application in the subordinate directory inherits the entries from the root application. So, extensions, handlers, providers, etc.

    The solution is a little counterintuitive. You would think that you could tell the subordinate application (Wiki) to ignore any configuration changes that are made higher up in the hierarchy, but you can’t.

    You need to tell the root application not to send configuration to any subordinate applications.

    It looks something like this.

    <configuration>
        <configSections>
            …
        </configSections>
        <location path=”.” inheritInChildApplications =”false”>
            … rest of config
        </location>
    </configuration>

    Many thanks to Nikhil and Clint for the data !

    Fixing an ASP.NET 2.0 App after upgrading to 3.5

    When you first open an ASP.NET 2.0 website in Visual Web Developer / Visual Studio 2008, VS asks you if you want to upgrade the project to 3.5.

    As some of you who are using Microsoft AJAX and who say YES to upgrade to 3.5 have noticed, when you go to run your newly upgraded application (which worked fine before the upgrade), you get build errors !!!

    The build error complains that it can’t load System.Web.Extensions Version 1.0.61025.0

    That’s the OLD version of Web.Extensions (AJAX)  that works with ASP.NET 2.0.

    You’ll note a number of references in your web.config file to this old version. Since before the 2008 release wave, MS AJAX was loaded via separate assemblies and since it is now “baked in” to ASP.NET, it’s hard for the upgrade tool to know that you don’t need the referenced version.

    So….. In your web.config change all the 1.0.61025.0 version references to 3.5.0.0 (unless you are using some CTP or Futures Version)

    If you are using the AJAX Control Toolkit there is still a bit of work to do.

    You will now get this error on your Toolkit Control instances.

    Download the version of the AJAX Control Toolkit that is built for ASP.NET 3.5

    Note: There are separate versions for ASP.NET 2.0 projects and ASP.NET 3.5 projects.

    If your are running Windows Vista, Right-Click the .zip file, select properties, and “Unblock” the file.

    Then unzip the files to the location of your choice.

    Make sure the Visual Studio Toolbox Tab that you create for the controls is with the 3.5 version.

    Now you need to upgrade your project to use the new tool kit. The easiest way to do this is to let Visual Studio do it for you.

    SWITCH TO SOURCE VIEW and drag and drop any Ajax Control Toolkit control into your page.

    When you get this dialog SELECT APPLY TO ALL ITEMS and click yes.

    Then delete the control you just added.

    Visual Studio will have updated your controls reference and you should now be good to go !

    Getting up to speed with ASP.NET 3.5 and the 3.5 Extensions

    Learn More About Visual Studio 2008

    I get hundreds of email a day from customers. Yesterday I received three email with the same question.

    Do you have a few good links for getting up to speed with ASP,NET 3.5

    So…. Here you go.

    ASP.NET 3.5 and Visual Studio 2008

    http://www.asp.net/downloads/vs2008/

    http://msdn2.microsoft.com/en-us/library/s57a598e.aspx

    http://msdn2.microsoft.com/en-us/vstudio/aa700830.aspx

    http://csna01.libredigital.com/?urvs5cn3s8

    3.5 Extensions Links

    http://www.asp.net/downloads/3.5-extensions/

    http://www.asp.net/learn/3.5-extensions-videos/

    http://www.asp.net/downloads/3.5-extensions/readme/

    THEN …………………….

    Just subscribe to http://weblogs.asp.net/scottgu where you can get great detailed stuff.

    2 New AJAX How-Do-I Videos Released

    Here is the latest in my AJAX How-Do-I Video Series

    Hope you like them !

    How Do I: Retrieve Values From Server Side AJAX Controls

    How Do I: The AJAX Toolkit Reorder Control

    New 4 part series of videos on DOWNLOADING with ASP.NET

     I’m adding to my How-Do-I Video Series with 4 new videos to help you with a variety of upload scenarios, from simple file uploads to AJAX-style to multiple files. !

    Maarten Balliauw on ASP.NET load balancing and the ASP.NET state server.

    Please check out Maarten Balliauw’s great blog posts on ASP.NET State Partitioning and Load Balancing. 

    RIAnimation – Cool Free ASP.NET AJAX Control

    From the HushHushMedia.com web site….

    RIAnimation = Rich Interactive Animation

    Give your ASP.NET projects new life with RIAnimation. We have taken powerful JavaScript libraries (Prototype, JQuery and Interface) and developed a simple ASP.NET control for applying RIAnimations (Rich Interactive Animations) to any ASP.NET control. With RIAnimation, adding sophisticated interaction to your existing web apps is as easy as dropping our control on the form and setting three properties!

    [Click here for more info]

    ASP.NET Applications and User Interface Design Aesthetics

    I’m “aesthetically challenged” !

    Doing good “look and feel” work doesn’t come natural to me, and I want to change that. For both the demo applications that I will be using in 2008′s webcasts and videos, as well as for my “pet projects”, I want to build great LOOKING web applications (as well as great WORKING ones.)

    Visual Studio 2008 has some GREAT new designer and CSS support.

    I’ve recently finished recording a series of 8 videos on “What’s new in Visual Studio 2008″. They are currently in post-production and will hit the web within a week or two (I’ll blog a notice when they do.)

    The tool support really helps me use the technology, but I’ve still been struggling with the “what and why” of it. So, I started doing research, thinking I should doa vedeo series on the “designer” process of building ASP.NET application.

    There really isn’t much ASP.NET specific reference on the subject, but I though I woul share some of the stuff I came up with.

    First – you gotta read this book!

    Next, did you know there are hundreds of “ready-to-use”, free / Open Source” web designs out there ?

    Check out these sites for many of them.

    Of course, CSS is a MUST.

    I found these 2 books useful.

    CSS-Mastery CSS Cookbook

    CSS Mastery was a good tutorial, but the CSS Cookbook has a bunch of great examples that really helped me “wrap my head around” how to use CSS and what you can do with it.

    Here are some cool CSS oriented wen sites!

    And don’t forget the CSS Control Adapter Toolkit !

    CSS Control Adapter Toolkit for ASP.NET 2.0

    Do you have some great “Designing for ASP.NET” resources, tools, or ideas?

    Please send them to me!

    You can contribute to the ASP.NET AJAX Control Toolkit

    Did you know that there is an open contribution model for submitting new controls in the AJAX Control Toolkit ?

    This document provides some guidelines on how you could get your custom ASP.NET AJAX control added to the toolkit and therefore used by developers around the world !

    The document also contains pointers on how to submit fixes and feature additions for existing controls.

    Contributing to the Toolkit

    The AJAX Control Toolkit is a shared source project released under the Microsoft Permissive License and built on top of ASP.NET AJAX. It has a set of over 35 controls, many of which were written by members of the ASP.NET AJAX community. The Toolkit has matured into a stable and feature complete product through work with the community over the past year. We would like to continue our organic growth by defining a process for all Toolkit contributions.
    Contributions should add sound value to the Toolkit and serve its customers’ needs. Anyone wishing to contribute should be committed to a high quality bar and take responsibility for their code. There are two ways that our users can contribute to the Toolkit: use the Toolkit Patch Utility for bug fixes and new features for existing controls, or become a Toolkit contributor by adding new controls.

    If you already have a great control and would like to share it with us or if you would like to write a new control from scratch this is a great opportunity to challenge yourself to write great reusable controls, show-off your technical and design skills, get plenty of visibility, learn more about Shared Source at Microsoft.

    If your control goes into the AJAX Control Toolkit – email me, I’ll do a video about it !

    CAPTCHA Kinda Spam Prevention in ASP.NET

    Spammers really bug me.

    I’ve been working on this on-going sports related portal project (that probably will NEVER go live :)

    I love of hobby community sites degrade quickly because they lack the moderation resources to keep the user submitted content quality high and I’ve been thinking about this problem.

    I thought I would share some interesting links that I found on the subject.

    DotNetSlackers – Ajax Data Controls

    DotNetSlackers has just released Ajax Data Controls (ADC) as open source. The project is hosted at codeplex and there are several live examples which can be seen at the samples link below. 

    The ADC contains an AjaxGridView, AjaxDataList, AjaxRepeater and we are going to add more controls very soon as well.

    To get a feel for them, check out the samples page. Very cool stuff by “TheSlackers” !

     

    Are you making these 3 common ASP.NET AJAX mistakes?

    Check out Dave Wards advice on Update Panels and Postabacks at Encosia HERE.

    http://encosia.com/2007/10/24/are-you-making-these-3-common-aspnet-ajax-mistakes/

    Another Cool ASP.NET AJAX InLineEdit Label Control

    Check out ANOTHER cool ASP.NET InLineEdit AJAX Control.

    http://encosia.com/index.php/2007/08/23/seamless-inline-text-editing-with-aspnet-ajax/

    http://encosia.com/index.php/downloads/inline-edit-box-net/

    Bilal’s Cool ASP.NET AJAX InLineEdit Label Control

    Check out this cool ASP.NET InLineEdit AJAX Control that Bilal Haidar recently released.

    http://bhaidar.net/cs/archive/2007/10/03/asp-net-2-0-ajax-inlineeditlabel-control.aspx

    Understanding Dynamic ASP.NET Controls

    I was working on a demo of using MS AJAX and Dynamically adding ASP,NETControls to a page when I can across this great 4 part blog posting on the subject and wated to share it.

    http://weblogs.asp.net/infinitiesloop/archive/2006/08/25/TRULY-Understanding-Dynamic-Controls-_2800_Part-1_2900_.aspx

    Web Client Validation Bundle Ships

    You know that I love the work that the Patterns & Practices Guys do.

    Glen Block let me know about this new little gem for web developers.

    http://blogs.msdn.com/gblock/archive/2007/10/01/web-client-validation-bundle-shipped.aspx

    It uses AJAX methods to combine Client & Server side validation so that you get the great UI experience AND secure use r input.

    Check it out !

    Demo’s in a Shared Hosting Environment.

    Some time ago I blogged about Soft Sys Web Hosting.

    http://www.softsyshosting.com/

    I met Ruchir through on line correspondence and he really wanted to figure out how to provide great hosting at the most reasonable prices possible. (As a student he had been frustrated.)

    Well HE DID IT – plans start at .91c per month. That is NOT a typo – 91 Cents per month.

    Think you get get good service for that – I’m gonna test them out.

    I’e set up an account (it’s “Silver” – 1 domain with SQL )

    I’ve pointed a domain there http://aspdemos.com/

    No content yet – but I thought I’m do some webcasts on issues specific to the shared hosting experience.

    So, YOU tell me (use the Contact Link) what you want to see !

    Themes & Master Pages – Are they enough ?

    I’m not a graphics designer, not even close.

    In fact, I’m what you might refer to as esthetically challenged.

    So lately I’ve been toying with the idea of building an ASP.NET based CMS, mostly due to my frustration about the lack of .NET based options when compared to PHP.

    So I’ve been working on application architecture and ASP.NET offers lots of great synergies, but one place I’m stuck is in the area of UI abstraction for the purpose of themeing.

    I understand how themes and Master Pages work technically, but my lack of design acumen leaves me struggling when evaluating them for complex UI design.

    So, to get me started I picked up a copy of Jacob Sanford’s new book….

    ASP.NET 2.0 Design – CSS, Themes and master Pages

     

    I’ll blog a review and probably do some videos from what I learn, but in the mean time…..

    What are YOUR thoughts about Themes and Master pages ?

    What are the issues, tips, tricks, gotchas ?

    Are Themes & master Pages flexible enough to serve as a templating engine for an application like Joomla or am I better off building an HTML/CSS skinning system from scratch ?

    Thanks!

    Migrating from Classic ASP to ASP.NET

    A few links for migrating from Classic ASP to ASP.NET came through my inbox and I though some folks might find them usefull.

    1.       http://msdn2.microsoft.com/en-us/asp.net/aa336573.aspx

     

    2.       http://msdn2.microsoft.com/en-us/library/Aa479019.aspx

     

    3.       http://msdn2.microsoft.com/en-us/library/ms973813.aspx

     

    4.       http://msdn2.microsoft.com/en-us/asp.net/aa336623.aspx

    ASP.NET AJAX Shorthand Syntax

     

    Did you know that ASP.NET AJAX include these shorthand notations for commonly used commands ?

    $

    get(‘YourControlName’)

    Shortcut to Sys.UI.DomElement.getElementById – gets a reference to the DOM element, same as document.getElementById

     

    $find(

    ) 

    Shortcut to Sys.Application.findComponent

    $create() 

    Shortcut to Sys.Application.Component.create

    $addHandler(FormElement, EventName, HandlerMethod) 

    Shortcut to Sys.UI.DomEvent.addHandler

     $clearHandlers(FormElement) 

    Shortcut to Sys.UI.DomEvent.clearHandlers

     $removeHandler(FormElement) 

    Shortcut to Sys.UI.DomEvent.removeHandler

    ASP.NET AJAX Postback Event Validation

    In my video “How Do I Use the Cascading Drop Down Control Extender”  I demonstrate setting EnableEventValidation=”false” at the page level and mention that you can leave the default (which is true) and individually authorize client event.

    Since I’ve had a number of email about this, I thought I’d comment on the issue here.

    It turns out that it’s actually a bit tricky in the case of using the Cascading Drop Down Control Extender when the Drop-Down values are dynamic. (Meaning they come from a data-source where items might be added after your code is written.)

    The reason is that you need to SPECIFY what values are valid for the post-back.

    Example, in the Render or Pre-Render methods you could:

       ClientScript.RegisterForEventValidation( _MyList.SomeUniqueID, “Red”);

       ClientScript.RegisterForEventValidation( _MyList.SomeUniqueID, “Green”); 

       ClientScript.RegisterForEventValidation( _MyList.SomeUniqueID, “Blue”);

    The issue here is the “Red”, “Green” etc.

    Of course, you could pull them from the database at runtime and call RegisterForEventValidation for each value.

    Rather than write about all the details I’ll point you to a pair of excellent blog postings by K. Scott Allen over at OdeToCode.com

    Read HERE: http://odetocode.com/Blogs/scott/archive/2006/03/20/3145.aspx

    And HERE: http://odetocode.com/Blogs/scott/archive/2006/03/21/3153.aspx

    Thanks Scott! Good stuff !

    Force an UpdatePanel Update from JavaScript

    The ASP.NET AJAX UpdatePanel gets updated in one of 3 ways.

    1.) An implicit control event triggers an update (that is a control inside the UpdatePanel is getting updated, etc.)

    2.) The UpdatePanel has a <Triggers> Collection, and one of the defined triggers gets fired.

    3.) The UpdatePanel’s Update metod is explicitly called in the course of some server side logic.

    BUT…….  What if I want to explicity trigger an update to the UpdatePanel from my client side JavaScript code ???

    Ceck out his link on CodeProject for a solution.

    http://www.codeproject.com/useritems/UpdatePanelScriptExtender.asp

    Getting ReorderList Item Values

    I customer email me asking how to iterate the values of items in the AJAX Control Toolkit ReorderList Sample.

    Thanks to Shawn Burke for the hints. 

    Here is how you get to them.

    Assuming an Item template that includes 2 label controls…..

     

        1     Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

        2         Dim l1, l2 As Label

        3         Dim i, max As Integer

        4 

        5         Label3.Text = “”

        6         max = ReorderList1.Items.Count – 2

        7         For i = 0 To max

        8             l1 = CType(ReorderList1.Items(i).FindControl(“Label1″), Label)

       09             l2 = CType(ReorderList1.Items(i).FindControl(“Label2″), Label)

       10             Label3.Text = Label3.Text + “  “ + l1.Text + “  “ + l2.Text + “<br />”

       11         Next i

       12     End Sub

    ASP.NET Membership Admin without Visual Studio

    I found this somewhere out on the web – my apologies to the original author as I didn’t record it’s origin.

    Using the default ASP.NET 2.0 Membership (AspNetSqlMembershipProvider) you can modify config settings and add/remove users from the Visual Studio IDE if you are running it locally or FrontPage Server Extensions are installed and you are connected remotely to the site.

    If you want to use the ASP.NetWebAdminFiles web interface without Visual Studio, as I recently did, then here is what you do.

    FYI: Only do this if you are careful and for the right purposes, since you are exposing some administration capability.

    1. Create a virtual directory that points to the web admin files.
    This is what I did:

    VirtualDirectory: ASP.NetWebAdminFiles
    MappedTo: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles

    2. Modify the properties of the virtual directory so that it is running under ASP.NET 2.0. (Properties > ASP.NET)

    NOTE: if you are running 1.1 and 2.0 applications on the same server or site, you may have to set up a separate application pool for the 2.0 sites. If you get the notice, “Application Unavailable” then that is why.

    3. While you are there, remove anonymous access to that virtual directory.

    4. After that, you will be able to connect to the web admin tools using the following url syntax

    http://localhost/ASP.NETWebAdminFiles/default.aspx?applicationPhysicalPath=XXX&applicationUrl=/YYY

    in my case, it is:

    http://localhost/ASP.NETWebAdminFiles/default.aspx?applicationPhysicalPath=C:\inetpub\wwwroot\myapp\&applicationUrl=/myapp

    NOTE: Although it isn’t recommended, if you want to access web admin tool from a different/remote computer, then open the WebAdminPage.cs file from the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles\App_Code directory and comment the following code block:

    if  (!application.Context.Request.IsLocal) 
       {
       SecurityException securityException = new SecurityException((string)HttpContext.GetGlobalResourceObject(
                                                                            ”GlobalResources”, ”WebAdmin_ConfigurationIsLocalOnly”));

       WebAdminPage.SetCurrentException(application.Context, securityException);
       application.Server.Transfer(“~/error.aspx”);
      }

    The web admin tool will still be protected to some degree by the Integrated Windows Authentication.

    NOTE: If while trying to update user information you get the following error:

    Failed to update database “C:\inetpub\wwwroot\myapp\App_Data\ASPNETDB.MDF” because the database is read-only.

    Then the NETWORK_SERVICE account does not have read/write access to the MDF file that is being used to store the user information.

    http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=dd6d161b-df08-40bc-b9ed-fbca71949ddc

    AJAX Grid and Slider Navigation

    Every day a few folks send be pages of code and ask be to make it work for them (No Kidding)

    Joshua Folkets is a developer that I had dialog with in the past and this we we sent me code for me to USE rather han fix.

    What a treat – he just sent to me and said “I thought I’d send you this in case you find someone who might use it.”

    And here is a link to the code (use at your own risk) …..

    http://www.joeon.net/downloads/SliderGrid.zip

    Joshua – You ROCK !

    REALLY Inexpensive ASP.NET Web Hosting

    One of the cool things about my job is that I get to make friends all over the world.

    I met Ruchir when he emailed me as a student looking for inexpensive hosting.

    Well, Ruchir had allot of trouble finding what he was looking for and has remembered that experience – so he’s started a small hosting company with really reasonable hosting offers.

    ASP.NET Hosting starts at $10.99 a YEAR !

    Check it out here: http://www.softsys.org/

    New – AJAX Patterns Video Series

    This week I launched the first in a series of Videos on AJAX Patterns with the ASP.NET 2.0 Extensions for AJAX

    I’ll be releasing 1 or 2 a week and have about 30 topics identified.

    PLease check out the first one and sne dme your comments and suggestions.

    How Do I: Implement the Predictive Fetch Pattern for AJAX?

    Demonstrates an implementation of the Predictive Fetch pattern for AJAX, where the AJAX engine uses the current state of the user’s interaction to predict which set of content will be needed next, and then fetches that data in advance from the server. This provides for a more responsive user experience.

    Presented by Joe Stagner

    Duration: 24 minutes, 45 seconds

    http://asp.net/learn/videos/view.aspx?tabid=63&id=100

    Free ASP.NET AJAX 1.0 "How Do I?" Videos (Updated for Final Release)

    You can watch all of the videos online for free at: http://www.asp.net/learn/videos/ (also make sure to check out the more than 50+ other videos on that page as well).

    I am now working on a NEW series – “AJAX Patterns with the ASP.NET AJAX Extensions”.

    MS AJAX – Page Methods stop working with RTM Version ?

    Set  EnablePageMethods=true on your ScriptManager.

     

    Page method proxies are no longer created by default.

    CollapsePanel Extender FLASHING on Page Load ?

    This was really bugging me and I guess others as well.

    In the forums they thought it was a bug in IE6 (http://forums.asp.net/thread/1488886.aspx), but I was getting the same behavior in IE6, and Firefox

    Setting the Height in the content panel (the collapsable area) to 0 solved the problem for me in IE and Firefox.

    <asp:Panel ID=”ContentPanel” runat=”server”

         CssClass=”collapsePanel” Height=”0″>

     

    Anyone who still has IE6 installed, let me kow if you still get the panel “flash” on page load.

    Introduction to the PopupControl Extender

    Check out this cool article by Brian Mains.

    In addition to the titles topic it contains a good description of extender controls.

    Introduction to the PopupControl Extender.

    AJAX Service TimeOut question from yesterda’s Live-From-Redmond !

    Yesterday someone asked how to manually set Service Call Timeouts.

    I had no idea.

    But Bertrand Le Roy did. (Bertrand is an Engineer on the team and seems to know EVERYTHING about MS AJAX)

    Ayway – Bertrand pointed me at these.

    Sys.Net.WebRequest.set_timeout

    Sys.Net.WebRequestManager.set_defaultTimeOut

    I didn’t see these in the documentation (and it’s not searchable yet) but  after I know what to look for… there it was.

    Thanks (again) Bertrand !

    Miscroft AJAX and Caching

    Make sure debug=false is set in the <compilation> section in config.

    Then the web resource URLs will be cached (like the client libraries).

    The “t=” in the web resource URLs represents the assembly’s last modified date.

    As long as you don’t change the atlas assembly, the same “t=” should be generated.
     
    Proxies should get cached as well.. They are retrieved from the server as the browser parses the page, and loads referenced scripts.

    This is completely orthogonal to server lifecycle events such as Page_Init.
     
    There are some enhancements for caching in MS AJAX RTM  that make the scenario even better.

    Thanks to Nikhil Kothari for my edification.