Ivan Porto Carrero

IO(thoughts) flatMap (_.propagandize)

21

Jul
2006

Make 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 }

20

Jul
2006

Now 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/

17

Jul
2006

I 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

 

16

Jul
2006

Voting 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](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](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.

 

03

Jul
2006

AjaxPatterns.org

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

            [http://ajaxpatterns.org/](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.

30

Jun
2006

Javascript Obfuscation

I’ve been getting much better along with atlas lately. Almost up to the point that it takes me almost the same time to create page in asp.net than it does me to create a page in atlas. Notice the word almost :) And that’s optimism talking

Anyway it does take a wee while longer to create an atlas page than it would to create an asp.net page. But the result is about 10x as usable and than a normal page.

That being said. All that atlas goodnes comes at a cost : A lot of javascript being pushed down to the browser. When I was in wellington on wednesday there was somebody talking about atlas in the user group.  Seen as I will go talk to the regional groups I was quite keen what Tatham had to say on the subject.

It was interesting but at a certain point he talked about the “obfuscated” javascript files. Those are just packed. That made me think that I also want to have packed javascript that is slightly less readable. I remember I have some open source library that I downloaded a year or so ago.

Well the guy has a nice library that you can download here :

http://dean.edwards.name/packer/

It’s nice but his HttpHandler doesn’t work for me. But there’s a simple work-around. Make your own handler that reads the javascript file and uses his Pack function.

If somebody is interested in the code just drop me an email and i’ll send it to you.

28

Jun
2006

Safari Fix for the Client Library of Atlas

If you’re not using the control toolkit for atlas and are doing some client side scripting. you may find that the April CTP has doesn’t always work in the safari browser.

This is in part due to the way that safari attaches events.

In the control toolkit they use the following script to “patch” the april CTP of atlas to support safari a whole lot better. Some might find it useful :-)

   40     // This fixes a bug in the Atlas Safari compatibility layer that

   41  // prevents chaining multiple handlers to an event.  We will remove

   42  // this after an Atlas CTP refresh resolves the underlying issue.

   43  //

   44  if (window.__safari) {

   45     window.console.log(“Patching Safari compat layer”);

   46     (function() {

   47         var attachEventProxy = function(eventName, eventHandler) {

   48             this.addEventListener(eventName.slice(2), eventHandler, true);

   49         }

   50 

   51         var detachEventProxy = function (eventName, eventHandler) {

   52             this.removeEventListener(eventName.slice(2), eventHandler, true);

   53         }

   54 

   55         window[“HTMLHtmlElement”] = document.createElement(“html”).constructor;

   56 

   57         function HTMLElement() {}

   58 

   59         HTMLElement.prototype = HTMLHtmlElement.proto.proto;

   60         var HTMLDocument = document.constructor;

   61         window.attachEvent = attachEventProxy;

   62         window.detachEvent = detachEventProxy;

   63         HTMLDocument.prototype.attachEvent = attachEventProxy;

   64         HTMLDocument.prototype.detachEvent = detachEventProxy;

   65         HTMLElement.prototype.attachEvent = attachEventProxy;

   66         HTMLElement.prototype.detachEvent = detachEventProxy;

   67 

   68     })();

   69 }

24

Jun
2006

Django vs Ruby

Ruby looks to me like a hack. I’m not the only one with problems there :)

http://tabo.aurealsys.com/archives/2005/10/11/django-or-why-i-chose-it-over-turbogears-and-ruby-on-rails/

I  decided to ignore Ruby for the moment and focus on Rails. What i noted:

  • Very simple to install and set up new projects

  • You create a database and it’s tables, and Rails will handle them

  • Things get messy when you want to write SQL instead of using the framework to access the data model

  • URL generation is simple but not flexible

  • Rails templates looked ASPish, horrible, almost cthulhian. I couldn’t stand the sight of them. There is too much code in them and worst of all, I couldn’t find a way to change the template system (Clearsilver in Rails anyone?)

24

Jun
2006

Modern Web Design Time Division

My friend Miel found this site from poisoned minds.

They have a nice breakdow on how time is really spent when developing a website. Of course this is good for a laugh :)

Poisoned mind webdesign piechart

I think they do have a point with the pure css lay-out. I for one am a dropshadow fan because if I put 2 divs on top of each other they need to look like there is some distance between them. I like the depth af the whole idea.  Up till now I haven’t found a way to create a rectangle with rounded corners and a dropshadow (like in photoshop or fireworks dropshadow) using only divs. I can do it easily using tables tho.

But IE users must die. People love to attack microsoft stuff and I think those that complain about the quirks in IE start developing their site for other browsers than IE and that’s where those people make a thinking mistake. The logic behind it is : if 95% of the users use IE why would you start developing a site that does not target this browser primarily.

Actually it is really starting to piss me off. All the time spent whining about how bad everything is what ms does, while working on a Windows XP machine with Office 2003/7 and visual studio on it, the time should be spent on making your life and the life of others easier. If you understand pc’s and coding a little it means you rarely have to be faced with the same problem twice.
I’ve been making websites for 8 years now, most of them not so pretty especially the first few years :)
And I haven’t come across the IE problem that all the others seem to be facing.  However i do have problems with browsers like Konqueror (this is just a piece of sh**), safari (Konqueror based say no more) and Opera.
Up to the point that i don’t want to spend the money on supporting those (except for safari if it is really necessary).

To top