Archive for July, 2006

29JulBase4 Totally rocks !!!

The last couple of days I have been playing around with base4 and I have to tell you if you aren’t using it now. You should hurry yourself to their site and start downloading.

We are in the process of testing a schema generator that will wrap your existing databases to the base4 schema file.

I have a code reduction of at least 33% with another OR/mapper so that counts in my book.

Hurry to base4.net

 

People interested in testing the mapper please email me or something.

25JulDisable page caching globally

I decided to put some of the questions I get from time to time on my blog, if they involve code samples at least.

Today :

Sent: Wednesday, 26 July 2006 10:18 a.m.

To: Ivan Porto Carrero

Subject: Page Caching



 

I use the following markup to disable caching for specific pages in my app.

<%@ OutputCache Location="None" VaryByParam="None" %>


 

Do you know how to do this gloablly, for whole application?


 

Answer:

void Application_PreSendRequestHeaders(object sender, EventArgs e)




    {



       




        Response.ContentEncoding = System.Text.Encoding.UTF8;





        Response.Cache.SetCacheability(HttpCacheability.NoCache);



 




    }



 

Add that to the global.asax that will disable all caching


 

More info on the HttpCacheability object :


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpcachepolicyclasssetcacheabilitytopic.asp

 

23JulSome choices made regarding NBlogr

For the development of NBlogr I had to say goodbye to some of my favorite controls.

The idea of NBlogr is that it is Open Source so that means I can’t use anything that is not open source / free in my project.  I use component arts excellent menu whenever I see fit except for now.

ComponentArt have 2-3 controls in their range that I really like. The other ones aren’t really usefull in my case.

I’ve been using the freetextbox control for 3,5 years now. But the latest versions aren’t really good implementations. If I load up my control in a firefox browser and I reload the site by entering in the address bar.. I get 3-5 errors @ pageLoad.  And that just sucks because the rest of the javascript doesn’t get executed and an atlas page won’t execute.

So for me it’s down with the freetextbox control and up with the tinymce control from moxiecode.
That one is the only true cross browser (IE, FF, Safari, Opera) richt text editor I can find

Another benefit : It’s smaller than the freetextbox and loads way faster.

Captcha isn’t a good solution for blocking comment spam. I’ve decided to use akismet as a refferer and comment blacklist service for NBlogr.

 

23JulCongrats to Tim and his wife with their new baby

Tim Haines became a father over the weekend.

Congratulations to the happy family. I wonder if the little one will take after the father and start googling away after a few months/years :)

http://ims.co.nz/blog/archive/2006/07/22/1856.aspx

 

A picture of the adorable baby :

Tane Haines

21JulMake the freetextbox work inside an atlas updatpanel

A while ago I blogged about making the freetextbox work inside an updatepanel. I didn’t put the code at that time because it wasn’t what it should be.

For the NBlogr engine I do need a working version of that control. And it should work on firefox and internet explorer. Now I have it somewhat working.  I thought it would be best to share this, as I’m sure that there are others that are facing the same problem.

You basically wrap it in an iframe so that it loads it’s script in a page that does not have an update panel on it.
through javascript you get the value of the entered in the freetextbox and set it in an hiddenfield. and voila you’re done.

FreeTextBoxWrapper.ascx :

<


iframe


runat
=”server”


id
=”ifrmTxt”


width
=”600″


height
=”400″


frameborder
=”0″


>
iframe
>

<


asp
:
HiddenField


ID
=”hfFtbValue”


runat
=”server”


/>

And the codebehind for the ascx :

12 [ValidationProperty("Text")]

13 publicpartialclassApp_Components_FreeTextBoxWrapper : System.Web.UI.UserControl

14 {

15 publicstringText

16 {

17 get

18 {

19 returnhfFtbValue.Value;

20 }

21 set

22 {

23 hfFtbValue.Value = value;

24 }

25 }

26 publicstringWidth

27 {

28 get

29 {

30 returnifrmTxt.Attributes["width"];

31 }

32 set

33 {

34 ifrmTxt.Attributes["width"] = value;

35 }

36 }

37 publicstringHeight

38 {

39 get

40 {

41 returnifrmTxt.Attributes["height"];

42 }

43 set

44 {

45 ifrmTxt.Attributes["height"] = value;

46 }

47 }

48 protectedvoidPage_Load(objectsender, EventArgse)

49 {

50 //load the freetextbox page that has no theme and no masterpage set. The background color is the one I chose to blend in with my design

51 ifrmTxt.Attributes["Src"] = ResolveUrl(string.Format(“~/App_Components/FreeTextBox.aspx?hf={0}&w={1}&h={2}”, hfFtbValue.ClientID,Width,Height));

52 ifrmTxt.Attributes["Name"] = ifrmTxt.ClientID;

53

54 if (!IsPostBack)

55 {

56 Session[hfFtbValue.ClientID] = hfFtbValue.Value;

57 }

58 }

59

60 protectedoverridevoidOnDataBinding(EventArgse)

61 {

62 base.OnDataBinding(e);

63 Session[hfFtbValue.ClientID] = hfFtbValue.Value;

64 }

65 }


And the page that contains the freetextbox control :

<%


@


Page


Language
=”C#”


AutoEventWireup
=”true”


Theme
=”"


CodeFile
=”FreeTextBox.aspx.cs”


Inherits
=”App_Components_FreeTextBox”


ValidateRequest
=”false”
%>


DOCTYPE


html


PUBLIC


“-//W3C//DTD XHTML 1.0 Transitional//EN”


“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<

html


xmlns
=”http://www.w3.org/1999/xhtml”


>
<

head


runat
=”server”>

<
title
>
A wrapper for the freetextbox in an atlas:updatepanel

title
>

<
style


type
=”text/css”>

body
{

background
:
#ffdaa0
;//Set your color here

margin
:
0
;
}


style
>

head
>
<

body
>

<
form


id
=”form1″


runat
=”server”>

<
div
>

<
FTB
:
FreeTextBox


ID
=”ftb”


runat
=”server”


SupportFolder
=”~/”


ClientSideTextChanged
=”onFtbClientTextChanged”>

FTB
:
FreeTextBox
>


div
>


<
script


type
=”text/javascript”>

//The lengthy constructor is there so that firefox also knows where to get the text.

function


onFtbClientTextChanged
(){

window
.
parent
.
document
.
getElementById
(
‘<%= MainPageField %>’
).
value
=
document
.
getElementById
(
‘<%= ftb.ClientID %>_designEditor’
).
contentWindow
.
document
.
body
.
innerHTML
;
};


if
(
navigator
.
userAgent
.
indexOf
(
“Firefox”
)!=-1)

document
.
getElementById
(
“<%= ftb.ClientID %>_htmlEditorArea”
).
addEventListener
(
‘change’
,
onFtbClientTextChanged
,
true
);
//for firefox


script
>



form
>

body
>

html
>

With it’s codebehind:

12 publicpartialclassApp_Components_FreeTextBox : System.Web.UI.Page

13 {

14 protectedstringMainPageField;

15

16 protectedvoidPage_Load(objectsender, EventArgse)

17 {

18 MainPageField = Request.QueryString["hf"];

19

20 if (!IsPostBack)

21 {

22 //When the page first loads we need to set the freetextbox with the value from the hiddenfield for databinding etc.

23 stringsetTextScript = string.Empty;

24 if(Request.Browser.Browser != “IE”)//for firefox we need to reach the freetextbox design editor to place our html

25 setTextScript = string.Format(“document.getElementById(‘{0}_designEditor’).contentWindow.document.body.innerHTML = window.parent.document.getElementById(‘{1}’).value;\r\n”, ftb.ClientID, MainPageField);

26 else

27 setTextScript = string.Format(“document.getElementById(‘{0}’).innerHTML = window.parent.document.getElementById(‘{1}’).value;\r\n”, ftb.ClientID, MainPageField);

28

29 Page.ClientScript.RegisterStartupScript(this.GetType(), “setText”, setTextScript, true);

30 ftb.Text = Session[MainPageField].ToString();

31 }

32 //Set the width to 99% so that the freetextbox displays completely

33 ftb.Width = Unit.Percentage(99);

34

35 //Get the height and widht and set the height relative to the width of the iframe (the toolbars move)

36 intheight = int.Parse(Request.QueryString["h"]);

37 intwidth = int.Parse(Request.QueryString["w"]);

38 if (width < 550)

39 ftb.Height = Unit.Pixel(height – 130);

40 elseif (width < 600)

41 ftb.Height = Unit.Pixel(height – 120);

42 else

43 ftb.Height = Unit.Pixel(height – 90);

44

45 }

46

47 }

20JulEvent logging made easy in asp.net

To log events/errors in your application, asp.net 2.0 has the healthmonitoring api that lives in System.Diagnostics.

You can get it to log just about anything that happens on your web app. To configure it, it takes you 15 minutes the first time and after that about 2 minutes.

You configure the asp.net services in the sql database.

To run the aspnet scripts on the database : attach the database to sql express via the management studio or something Give it a shorter name.

Then open a command prompt and navigate to %windir%\Microsoft.NET\Framework\v2.xxxxxxx

 

Next run aspnet_regsql – S servername -A all -d dbShortername

 

<
system.web
>

              <
trace


enabled
=


true



requestLimit
=

25



pageOutput
=

false



traceMode
=

SortByTime



localOnly
=

false

/>

              <
healthMonitoring


enabled
=


false

>

                     <
bufferModes
>

                           <
add


name
=


Critical Notification



maxBufferSize
=

100



maxFlushSize
=

20



urgentFlushThreshold
=

1



regularFlushInterval
=

Infinite



urgentFlushInterval
=

00:01:00



maxBufferThreads
=

1

/>

                           <
add


name
=


Constant Monitoring



maxBufferSize
=

1000



maxFlushSize
=

100



urgentFlushThreshold
=

100



regularFlushInterval
=

00:05:00



urgentFlushInterval
=

00:01:00



maxBufferThreads
=

1

/>

                    
bufferModes
>

                     <
providers
>

                           <
add


name
=


MySqlWebEventProvider



type
=

System.Web.Management.SqlWebEventProvider



connectionStringName
=

connectionStringName

                                 
maxEventDetailsLength
=


1073741823



buffer
=

true



bufferMode
=

Constant Monitoring

/>

                           <
add


name
=


CriticalErrorMailProvider



type
=

System.Web.Management.SimpleMailWebEventProvider



from
=


monitoring@sitedomain.com




to
=
“tryit@nospam.com



priority
=

High

                                 
bodyHeader
=


ERROR !!!



bodyFooter
=

Please investigate ASAP



subjectPrefix
=

Problem at [sitename].



maxEventLength
=

4096



maxSize
=

4096



maxMessagesPerNotification
=

1

                                 
buffer
=


true



bufferMode
=

Critical Notification

/>

                    
providers
>

                     <
profiles
>

                           <
add


name
=


siteDefault



minInstances
=

1



maxLimit
=

Infinite



minInterval
=

00:10:00

/>

                    
profiles
>

                     <
rules
>

                           <
add


name
=


All Events Default



eventName
=

All Events



provider
=

MySqlWebEventProvider



profile
=


siteDefault




minInstances
=

1



maxLimit
=

Infinite



minInterval
=

00:01:00



custom
=
“”
/>

                           <
add


name
=


Request Processing Errors



eventName
=

Request Processing Errors



provider
=

CriticalErrorMailProvider



profile
=


siteDefault


/>

                    
rules
>

             
healthMonitoring
>




system.web
>

The same type of functionality exists for asp.net 1.1 and is called elmah. Elmah lives on gotdotnet.



http://www.gotdotnet.com/workspaces/workspace.aspx?id=f18bab11-162c-4267-a46e-72438c38df6f



20JulNow here’s an interesting idea with good tips on raising starting capital for your idea.

A few weeks ago I came across the concept of Crowd source.

You can read more about it here : http://www.cambrianhouse.com

I suggest you have a read through their site because that is pretty cool.  They are currently in beta but are really friendly and helpful and welcome all new members.

I already know where I’ll be getting “hobby” projects from because there are some interesting idea’s on that site.

Today I had a browse through their blog and found a post where the founder of cambrianhouse explains how he raised 2.5 million USD and more importantly he shares his tips in depth:

Tip 1: Sincerely believe.
Tip 2: Screw the business plan. Tell them your story.
Tip 3: Sh#t confidence.
Tip 4: Pretend you already have the money.
Tip 5: Don’t marry every woman you date.
Tip 6: Prime the pump.

You can read more about it here : http://www.cambrianhouse.com/blog/startups-entrepreneurship/raising-capital-six-tips-on-eating-fear/

17JulI opened a workspace for NBlogr on gotdotnet

Today I opened a workspace on gotdotnet for an open source blog engine I started writing.

Everybody is welcome to join in. The space I have on gotdotnet is not so big which means that you’ll have to email me for now to get the complete and current source database.

A little bit later this week I will have a demo site/blog running on http://www.nblogr.com

The characteristics of the blog are :

1. It’s Atlas :)

2. It’s free for everybody to use

3. It’s open source so please if you change something then let me know.

4. Will be focussing on integrating the whole web 2.0 (the real web 2.0) experience i.e. direct integration of flickr etc.

5. The conversion from your current blog software should run without glitches.

I am definitely in need of somebody that knows how to create good templates/xhtml/css designs because that is not my strongest side.

The workspace is located @ http://workspaces.gotdotnet.com/nblogr

 

16JulVoting for blog of the year NZ has opened

You can vote for your favourite blog here :



http://www.dot.net.nz/Default.aspx?tabid=51

And you can vote for mine here :

http://www.dot.net.nz/blogvote?blogname=Ivan Porto Carrero

On thursday I have the first presentation about Atlas in our local user group.  I will try to support those talks with clear examples online of the concepts involved in atlas development.

 

03JulAjaxPatterns.org

For those of you that are concerned with design patterns for ajax check out this site :

http://ajaxpatterns.org/ 

I have to say that that site is a real gem.  I for one am concerned with usability and am not discriminating so I think the leap to accessibility is only very small.  We are planning an application that is ajaxed and should still be completely usable by blind users which will be intresting to build.

In preparation for this i stumbled upon http://www.maxkiesler.com/index.php/weblog/comments/how_to_make_your_ajax_applications_accessible/

That page has got about 40 links to sites that discuss accesibility in an ajaxed world.

The last issue I’m facing is the fact that because asp.NET renders webresource urls that are incredibly long. The w3 xhtml validator won’t validate my pages and only because of this url.  I want to render valid xhtml 1.1 pages. So that’s something I will be looking at in the next few weeks when I’ve got some spare time.


Recent Flickrs

    Blogroll

    Recent Listening

    Scrobbler