Aug 28, 2014

C# - What is Predicate?

Once I was looking for this for hours..
http://stackoverflow.com/questions/1710301/what-is-a-predicate-in-c

Aug 13, 2014

ASP.NET why Page_PreRender ?

So what's the purpose of Page_PreRender in ASP.NET webforms?

Easiest answer for me is through simple example.


  1. Create classic ASP.NET webforms with single ASPX
  2. Create 2 ASCX web user controls
Place in each code in Page_Load:

WebUserControl1.ascx


    public partial class WebUserControl1 : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "WebUserControl1";
        }

WebUserControl2.ascx

    public partial class WebUserControl1 : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "WebUserControl1";
        }


Register both on ASPX like this:

<%@ Page Title="About" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="WebApplication6.About" %>
<%@ Register Src="~/WebUserControl2.ascx" TagPrefix="app" TagName="web2" %>
<%@ Register Src="~/WebUserControl1.ascx" TagPrefix="app" TagName="web1"%>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">    
    <app:web1 id="ctrl1" runat="server" />  
    <app:web2 id="ctrl2" runat="server" />
</asp:Content>

Run web and observe that in browser  Tab Title is reflecting change from WebUserControl2.ascx Page_Load.
Now add Page_PreRender event in first one WebUserControl1.ascx:

   protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "WebUserControl1";
        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            Page.Title = "PreRender_WebUserControl1";
        }
    }

Run  and observe that now text from WebUserControl1's Page_PreRender event is shown instead of previous from WebUserControl2 Page_Load.

Same idea if you have filled Page_PreRender of ASPX.

Bottom line is to use Page_PreRender on only one place in your page elements (ASPX,ASCX) when you need to make sure that code in PreRender is the last modification to common page elements that are shared among all controls.

Jul 4, 2014

Publications / Magazine / NDC magazine

http://issuu.com/developermagazine/docs

DotNetNuke / module development / manifest

When developing DNN module extensions in your Visual Studio DNN Module project template there is manifest of your module with extension DNN.
Here is more:

http://www.dnnsoftware.com/wiki/page/manifests

Excerpts:

It should also be made known that each package equals one extension that can be managed in the DotNetNuke Extensions module, where they are grouped by extension type.


Although DNN does not expose a way to take a dependency on a particular .NET framework version, this can easily be emulated by taking a type dependency on a class that does not exist in prior framework versions. For example, to require .NET 4 as a precondition to installation, one may depend instead on the System.Tuple class (which was introduced with .NET 4.0):

<dependency type="type">System.Tuple</dependency>

There are a few things to be aware of when installing multiple packages within a single install (and thus, using a single manifest). First, packages are installed in the order they are declared in the manifest file (top to bottom). . This means, if you are installing a skin extension that also contains a skin object, you need the skin object to be installed prior to the skin being installed (thus, placing the skin object package towards the top, above the skin package). In this example, the skin object was used by the skin being installed and therefore it needed to be available prior to the skin being installed (otherwise, the skin object would not be rendered properly).