CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Peter's Gekko

public Blog MyNotepad : Imho { }

December 2003 - Posts

  • Moving a vs.net web project to another location

    According to the .text statistics this is my 100th post. Opinions, big blogs and statistics. To celebrate, something trivial.

    If you've ever moved a web project to a different machine or even to a different virtual dir of your local webserver you will have noticed vs.net will not open your project because it cannot find the project on the webserver. What works with me is a little patch in the solution-file using notepad.

    Steps:  (Where neccesary)

    1. Select the solution file (.csproj)
    2. Send it to notepad with the right mouse button
    3. Update the virtual dir in the second line
    4. Save the file
    5. Create the virtual directory in IIS admin
    6. Map the physical directory with the solution to the virtual dir
    7. Check "Script source access" in the virtual dirs properties

    The first part of the solution file will look similar to this :

    Microsoft Visual Studio Solution File, Format Version 8.00
    Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "loginSystem", "http://localhost/warnar/loginSysteem/loginSystem.csproj", "{30B12A58-89AE-4E65-A5B3-B4A16F5DD236}"

    If you update the url to the new location vs.net will open the project and you can continue to work on it.

    Blog on, a 100 still won't do... Peter

  • SUNy side of Christmas

    Today, the second day of Christmas, me and my family went to see Finding Nemo. We all had a great time. According to the credits the movie is “master renderded by (on?) Sun Microsystems”. Sounds almost classical. Could you imagine “mastered by Powerpoint to WMA” ?

    I could.....

    Blog on, Peter

  • (Un-) wanted

    Mark has spotted a blog police on the .net. Although the sherrif has aproved my blog (yuck..) I honestly think people should use a good newsreader to select the things they want to read instead of trying to shoot posts which might be interesting to others.

    It reminds me a little of my experiences with handling spam. It takes several steps to reach my inbox. First my provider uses a filter to send suspected mail to a junk mailbox. The mail which does make it over the wire is checked by Outlook 2003 which sends suspect messages to its junk box. I havn't seen Outlook make any false aquisations yet but my (respected) provider (xs4all) is far too strict. For instance, since two weeks all publications of Windows and .net magazine are considerd spam. To me WinInfo Daily Update is a major source of very good information and has a well working subscription procedure. So I find myself running daily through all the junk to get my beloved newsletter. Lifting the spam filter would result in 40+ spam, it is the risk of having a website with a working email address.

    To me the war on spam is resulting in (to much) collateral damage and I don't think shooting unintersting blog-post is worth any casualties at all.

    Blog on, say whatever you want to say. Become an outlaw !

    Peter

     

  • Inappropriate Abstractions

    Part 6 of Bill Venners (Artima) interview with Anders Hejlsberg is up : http://www.artima.com/intv/abstractP.html. More than just the title is catchy.

  • Strict Delphi for .NET (I want more than backward compatibility)

    Well, my last post on Delphi for .NET did raise some eyebrows....Was I to hard on Delphi because it was just a beta ? Personally I don't think so, it was not my first disapointment with Borland .NET stuff. And a beta should behave better than what I saw, especially if the release is anounced to be in 2003. Thats 2 weeks to go... Another reason for being hard is something I blogged about before in a comment on this. Imho Delphi people should be more critical to their own tool. I used to be like that as well. Actually I still am, only the direction has changed. My personal history goes back to Turbo 2 on my first PC, I'm still emotionally involved. And emotion is not allways the best driving force.

    I was wrong with strictly, it should be strict. Sorry, I did remember the word wrong. The main point I read from the comments is that Delphi for .NET aims at a great backwards compatibility. Nick has a point when he mentions projects which are started now, targetting Win32, and will be ported to .net sometime in the future. Using Delphi is a smoother ride then, and still nothing beats Delphi when it comes to Win32. But what will happen after the project migrated ? You can mix tools on the .net platform by definition. And Delphi with a dispose method named destroy and a visibility specifier private which actually means some kind of internal would raise some other eyebrows. Looking back it it al made sense but what about the future ?

    blog on,

    Peter

  • Delphi for .NET, strictly private

    Last friday I had the opportunity to see Delphi for .NET on the meeting of the sdgn The sdgn started long long time ago as a Clipper user group. Over the years, amongst other, Delphi and .net have joined the show. The sdgn was alway great in Delphi, so it was a nice environment to meet Delphi for .net.

    At this moment several betas of Delphi 8 are circulating. Delphi 8 is the same as Octane and Delphi for .NET. There will not be an other product to project your wishes or hopes upon. This is it ! It looks like C#-builder and houses the Delphi language targetting the .net platform. Not the Win32 platform, that will be added in a later release. You can port the source code of your Delphi VCL (the Delphi class libarary) app to Delphi 8. The VCL has been rewritten for the .net platform. A big difference between Delphi and a .net language is that you have to do your own memory management in Delphi and have a garbage collector in .net. Delphi still does have constructors destructors, their implementation is limited to the dispose pattern.

    The actual demo was actually a total disaster. Part of this was due to the speaker having to switch to another (someone else's) laptop to do the show. This machine had another Delphi version and possibly (?!) another D8 beta installed. But even some of the simplest thing did not work. Importing a Delphi 6 project which had one form with just one button failed. Another problem was that the speaker didn't seem to know that much about .net. He raved about the Delphi datamodule but could not answer what that had to offer over a .net component. What did work was live data in the designer. Provided you use the Borland database provider. According to the speaker this provider is quite essential, alas he was unaware that .net has a oledb data provider.

    The title of this post is from a new language feature of Delphi. In the current version fields scoped as private or protected are visible to other classes in the same unit (source file) Somewhat comparable to the internal scope in C#. To comply to the .net idea of private Delphi now also has strictly private and strictly protected. I don't like this either as it is further obfuscating the language. Now there is a destructor which does not destroy and there is a private which is not really private. If Delphi wants to make it into the .net area it will need the guts to do a cleanup. It will be a good tool to port existing Delphi apps to .net. But it's not inviting to build a future upon.

    Maybe I am coming down to hard on Delphi 8. I havn't been to friendly on C# builder either. I really do care a lot about Delphi and consider it a bloody shame what Borland is doing to their own heritage. The presentation and the product made my toes curl. I am not the only one. For instance : during the presentation the speaker mumbled, after another failure, “we'll have to find a solution for that”. Somebody else spoke out aloud what I only dared to whisper : “Use Visual Studio...”

    blog on,

    Peter

  • A PDC overview

    for those of you who can read Dutch, there's a story on the PDC on the site of the sdgn. For those of you to whom it is all Greek : the story has a couple of PDC foto's as well.

    blog on,

    Peter

     

  • Webservices and XML datasets

    As a compensation for last post, this one is 100% .NET.

    Using webservices you can pass data to and from a consumer. Using .net to build web-services this data can be quite complex , like a full XML dataset. This puts quite a big load on the wire, having to transport the bulky data and the consumer of the service, having to understand the data receieved. In an article I have studied three ways a service and its consumer can interchange and validate XML data

    • Using typed datasets
    • Using untyped dataset
    • Using XML in plain straing format

    The article was originally on my own webseite and has recently be republished on MSDNAA.

    blog on,

    Peter 

  • Nice days under darkest skies

    On music :  California dreaming in the North of the Netherlands.

    This post will not cover anything on .net, if that's what you're looking for : stop reading. This post will be entirely on music, if you think that kind of stuff doesn't belong here : let me know. I do believe music is quite an important topic amongst developers, regularly  many share some of their thoughts on the subject. Varying from the song they are listening to while blogging to a gallery of guitars. I cannot listen to music while programming but to me a piece of software (source code) does have things comparable to rhythm, melody and harmony. I know the software and the musical taste of some developers and do see a correlation between the style of the two.

    This post is not on guitars but on the human voice, the best musical instrument ever. If you have, like me, a post PDC California dreaming and keep hearing the Mammas and Pappas this one is recommended. Ygdrassil are a singing duo from the North of the Netherlands with harmonies which, amongst many others, do remind of a California dreaming. Ygdrassil's music is quite fragile, hopelessly romantic and absolutely hypnotizing. On the web are (part of) two samples from their latest album. The first shows their talent as a more classical singer-songwriter, the second one is a piece of vocal acrobatics firmly rooted in folk music. In case you get hooked, the album is availalble online. And there is a new one coming next year.

    Listen on,

    Peter

  • Writing on HTML in HTML

    Recently I blogged a little on the mixup of code and data and the way IE can mess things up. Today I was hit again by this phenomenon. In a post on generating a script snippet, like all web posts written in HTML, some of the tags intended as a piece of example code started getting interpreted by the html parser. The result was somewhat funny, parts of the text dissapeared, being taken for a comment. Part of the script examples were taken for “real“ code and popped up script errror dialogs.You don't want to know what a mess it was, deleting the block and writing it again (very carefully) was the only solution which really worked.

    blog on,

    Peter

  • The proper way to open a file dialog from your webpage

    Yesterday I blogged on the way to start a fileopen dialog from a web-page. Thanks to the feedback we discovered there's a very bad turn to that solution, the ActiveX control used only works on a machine which has MS devtools installed. Which is your or my machine but not that of the customer who is going to use the application. On the web I found a new solution which is pretty neat and doesn't need any ActiveX at all.

    In HTML there's the INPUT control of type file. It is an input box which automatically gets a button. Clicking this button will start the desired file-open dialog, completing that copies the filename into the textbox. Using the example found on the web I have crafted the following solution.

    • Create a hidden input file control
    • Create a script function which fires the click of the file-input control and copies the selected value into an asp.net textbox
    • Add an onclick handler to a button to fire this script function.

    This is the script snippet on the page

    <SCRIPT language=JavaScript> function BrowseClick(){
    document.forms[0]['fileBrowse'].click();
    document.forms[0]['TextBox1'].value = document.forms[0]['fileBrowse'].value;
    return false;}
    </SCRIPT>

    Which is a stripped version of the example found. Again I assemble the script from code

    const string fiName = "fileBrowse";
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.Append("<div style='visibility: hidden; width: 0px; height: 0px'>");
    sb.Append(string.Format("<input type=file id='{0}'></div>", fiName));
    sb.Append("<Script language=JavaScript> function BrowseClick(){");
    sb.Append(String.Format("document.forms[0]['{0}'].click();", fiName));
    sb.Append(String.Format("document.forms[0]['{0}'].value = document.forms[0]['{1}'].value;", TextBox1.ClientID, fiName));
    sb.Append("return false;} </Script>");
     

    RegisterClientScriptBlock(scriptKey, sb.ToString());

    ButtonLinkNaarDocumentatie.Attributes.Add("OnClick", "return BrowseClick();");

    This also works on my wife's XP-home machine. Thanks a lot to Andrew, Micheal Harris and Botolph.

    blog on,

    Peter

  • How to use a windows dialog in your webpage

    When you want to upload a file to the dnj site or the .text blog admin, a real Windows file open dialog pops. Quite cool and a piece of functionality I wanted for one of my own apps. Getting that done was, thanks to COM, easier than I had anticipated. So let me share this with you.

    A (file)dialog in a webpage is run by the browser. It is client-side code and has to a snippet of script. Personally I am not a great fan of scripting (too many things can go wrong at runtime) so the script snippet should be as small as possible. From the server side code of a web-page you can inject snippets of script from your C# (or vb.net) code. The nice way of creating the script that way is that you can leave a lot of the decision logic on the server and generate the smallest snippet imaginable. What I want to do is start a dialog and copy the name of the chosen file into a textbox. The Javascript to do that :

    <Script language=JavaScript>

    function BrowseClick(){
       var dialog = new ActiveXObject('MSComDlg.CommonDialog');
       dialog.Filter = 'All files (*.*)|*.*| ';
       dialog.MaxFileSize = 260;
       dialog.ShowOpen();
       document.forms[0]['TextBox1'].value = dialog.FileName;
    return false;}

    </Script>

    The function creates a commondialog COM object which wraps up all funtionality and exposes the essentials to script.  A larger story on all its possibilities is on MSDN, here I only set the required properties. The ShowOpen method of the COM object executes it after which the selected filename is copied into TextBox1.

    This script is only added to the page if there is a chance that it will be run, that is in the selected item template of a datalist. In my code it is a part of the datalist's ItemDataBound event.

    System.Text.StringBuilder sb = new System.Text.StringBuilder("<Script language=JavaScript> function BrowseClick(){");
    sb.Append("var dialog = new ActiveXObject('MSComDlg.CommonDialog');");
    sb.Append("dialog.Filter = 'Alle bestanden (*.*)|*.*| ';");
    sb.Append("dialog.MaxFileSize = 260;");
    sb.Append("dialog.ShowOpen();");
    sb.Append(String.Format("document.forms[0]['{0}'].value = dialog.FileName;", TextBox1.ClientID));
    sb.Append("return false;} </Script>");

    The script function is built using a stringbuilder. To insert the correct name of the textbox I use the ClientID property of the textbox control. This is the ID of the control in the browser, inside a template of a datalist or datagrid this ID will read something like "DataList1__ctl4_TextBox1" instead of  just "TextBox 1".

    RegisterClientScriptBlock(scriptKey, sb.ToString());

    The generated script is added to the page by a call to the RegisterClientScriptBlock method. After that it can be used by the controls.

    ButtonLinkNaarDocumentatie.Attributes.Add("OnClick", "return BrowseClick();");

    In the last line a click handler is added to a button. The clickhandler will call the registered scriptfunction. As that function returns a false the postback initiated with the buttonclick will be canceled. All processing is done on the client, there's no reason yet for any server involvement.

    The main thing to watch is the casing of your script. JavaScript is, like C#, also case-sensitive.

    Blog on,

    Peter

     

  • 100 issues of the Delphi Magazine

    Today the mailman brought the 100th issue of the Delphi Magazine. I had been a subscriber for quite a lot of years, but last year my subscription got sacrificed due to changing activities. But I still care about Delphi (mag) and felt a little guilty when I got my celebration copy. It contains a nice story on the history of Delphi and a good review of Delphi for .NET. The latter mentions an unique D8 trick : you can make calls to Delphi managed code from other unmanaged code, a kind of reverse P-invoke. The reviewer raves about it but I'm not sure. Besides all kind of (security) questions I miss mentioning the fact that you can call .NET code using COM. From any language, including something as subtle as VBscript. You have to decorate your assemblies and classes for COM -interop, which is good. As a developer you have (far more) control of what is being done with your code, any code just calling in scares me. Please correct me if I'm wrong.

    blog on,

    Peter

     

  • MSDN renewal

    I have renewed my MSDN subscription and found the process far better than last year. You used to receive a certificate with which you had to do the renewal yourself. Which resulted in the days left of the running subscription going up in smoke. Now the reseller does the prolongation, resulting in a full year. On the safe side. I did receive a packet, this contained a full VS.NET package. The CD's were nothing new but the huge pile of poster schema's is great. The ATL schema is not my cup of tea but the overwiew of the classes in the framework would look great next to the WinFx poster. The only thing missing is space on the wall

    blog on,

    Peter

  • Using Yukon in VS.NET Whidbey

    After the recent dotned meeting I promised to do some more on the Yukon possibilties of Whidbey. At this moment I am taking a tour but the way is somewhat hard to find. The documentation is absent, the code examples I've seen don't make that sense either and to Whidbey itself it is also a mystery what is there. What about this screenshot ? But there is a story in it.....

    blog on

    Peter

More Posts