in

ASP.NET Weblogs

Memi.Reflection

Private members of memi's thoughts

February 2004 - Posts

  • Server Control Lifecycle Conflict

    I'm working now on the UI controls framework of our company, and I've fallen into the following problem: I wanted to associate each input control to a text control, so that when the input control “visible” property is set to false, its title won't be visible either. For this to happen, I've defined a “TitleControl” property to each of the input controls, which contains the name of the title control associated with it. So far so good, and quite trivial. The problem began when I tried to figure out where exactly to put the code which hides the associated control.

    My first choice was in the “Visible” property code itself (which I overrode). I found out this was not possible, since if the control is defined as not visible in the designer, the associated control may not even exist in the page when the Visible property is set.

    The second one was on the “Load” control event. This solution presented another problem, since the framework (our framework, not the .NET framework) sets the visibility of the controls in the Load event of the page, which occurs AFTER the Load event of the controls.

    The third, and so far last, try was to put it in the PreRender event of the control. This proved to be a bad idea, since if the control is not visible, the PreRender event (and its OnPrerender handler) does not even get called.

    Scenarios like this make me sometimes wish I had another control event, something like “PageComplete” or “PostLoad“ which trigerred once the page, and not the control, is loaded. Until we'll have something like that (all the “Whidbey“ gurus out there - does it bring any change for this one?), there will be no event which will enable us to access the page after it was fully loaded, if the control is not visible.

    The workaround I found for this specific scenarion is to add handler to the Page.Load event from the control, but this is not the most elegant solution that should be availabe.

    Did you also had issues with the control's lifecycle? Did you find a better solution than mine? Pls let me know.

  • YAVSDB

    (Which stands for Yet Another Visual Studio Designer Bug)

    Try this:

    1. Create a new ASP.NET application

    2. Create a new class which inherits from Page. Call it, for example, MyPage.

    3. Declare the following class level variable:

    Protected WithEvents MyHidden As System.Web.UI.HtmlControls.HtmlInputHidden

    (or any other web control of your choice, such as textbox, listbox and so on)

    4. Create a new webform, and switch to the code behind file.

    5. Change the ancestor page name to be “MyPage“, or whatever you named the class.

    6. Switch to HTML view, and add the following HTML tag:

    <input type=”hidden” runat=”server” id=”MyHidden”>

    7. Compile the project.

    Now, if you switch to the Designer mode of the .aspx page, you'll see it added a declaration for this field in the code behind file of the webform, which will result in immediately an error, since the control already exist in the ancestor page.

    This is a really strange behavior, since if you'll delete the problematic line from the code behind, you'll be able to define events for it, which is understandable because it exists in the parent. It looks like the designer, when translating the content of the aspx to the code behind file, does not check whether there is already a definition for the controls in the class chain.

    This bug gave me some real hard times. The only workaround I found was to add the control in runtime, which is much less elegant, and when I throw in the “designer can't show page inherited from abstract page class” bug, then creating a really extensible and dynamic base page framework become much harder and less elegant than it should.

    Did you also encounter this behavior? Did you find a better solution than mine? If so - please let me know!

    Posted Feb 26 2004, 01:59 PM by memi with 1 comment(s)
    Filed under:
  • Foo & Bar

    Since my early programming days I've seen code samples with Foo and Bar as method and variables names.

    I've googled for their source, but just couldn't find anything about them. Maybe someone here can help me, and write where did this couple come from, and what is the meaning of them? Why did the software industry picked those two names instead of something less exotic, like A and B?

    Posted Feb 24 2004, 03:20 PM by memi with 5 comment(s)
    Filed under:
  • VS.NET Templates

    One of the nice features of the VS.NET is the possibility to add new templates to the project items. This feature is extremely handy when one creates a unique template, which should be used across all the application in the company.

    Our web framework, for instance, uses special pages types, and divided roughly to 3 types of pages: Base Page, Search Page and Update Page. Therefore, it was very useful to add the appropriate template to the VS.NET. This way, when a developer wants to add new web form, he can choose the most appropriate template to start work from, and he does not need to cut and paste the regular code of the WebForm template.

    That been said, there is a problem with this process. It is very cumbersome and error prone, and involves modifying vsdir and vsz files, as well as messing with scripts no one understand, not to mention debug.

    Am I the only one to feel this way? Did you also fell into the “Template Trap“? I think of creating a small Add-In which will automate this process, and help placing all the files in their right place. Do you think this tool would be useful for you?

    Drop me a line!

  • .NET - J2EE Intercopytability

    We've witnessed recently a growing flood of articles about the .NET - J2EE interoperabiliy. Looks like the fighters have come to rest, and now the negotiators start to speak. Anyway, I would like to write about somethig I call The .NET - J2EE Intercopytability.

    As time goes, there are more and more similar features in both platforms. I had a discussion today with the Java team leader, and he gave me a brief introduction to the new JDK 1.5 . Some of the features, like Enums, made me bless my fortune of going in the .NET path, but some of them took me by surprise. What would you say about the much acclaimed Generics? Looks like the Java folks are going to enjoy this in about 5 months, while we'll have to scratch our nails until dec. 2004 (hopefully).

    Now, while in this feature it's really not so clear who was the first, there is another feature, which is not a generic part of the JDK 1.5, but is a good example of one technology looking at another, and say “I want this feature too!”. I'm talking, of course, about the JSF technology. After reading the overview of this feature, one can't escape thinking it was copied from the ASP.NET overview. All the basic strcuture of seperate UI controls, events, adapters and so on is there. However, looks like the Java folks couldn't resist the inner urge to include XML file with every new feature, and so the poor programmer who would like to implement the JSF, will have to start coding XML.

    Bless you, web.config!

  • .NET Presentation

    I'm going to open a .NET course at our company, to educate all the developers with the .NET platform. Since I don't have too much spare time I would like to use existing presentations, and not to reinvent the wheel, not to mention my poor presentation design skills.

    Do you know of a good source for presentations (ppt format) about the .NET technologies? (ASP.NET, ADO.NET, WebServices... you name it) I've already checked the Resources at INETA, but couldn't find something useful.

  • The newbie syndrome

    Today I performed an application review from a usability and functionality viewpoint. I had about 1.5 hours to go over a not-so-big site (actually, 3 pages developed in JDeveloper. Nothing to do with .NET in this post, folks.), and after that I was to give my conclusions about the usability of it.

    My hosts were quite surprised when I came to them with about 50 problems I discovered. When we started going over them one by one, I discovered that there was something common with most of the problems: They were caused by developers thinking like developers, and not like users.

    I know this is a well known (sad) fact, but this case was an excellent demonstration on this issue. I think there is not enough awareness to this subject, and a lot of times, when a newbie joins a developers' group, he is taught about programming principles, OOP, SOA, and some more fancy buzzwords, but almost never told about usability principles, which can be summarized to: “When you develop a web page, try to do it from the user viewpoint, and not yours.”

    Let me give you an example. In this site, there were some date fields. The date should be typed manually into it (a problem in itself), and if the entered date format is incorrect, an appropriate message will appear. The message, in this case, was (translated from hebrew):

    “The date format is incorrect. Enter valid format: dd/mm/yyyy”.

    Now, maybe for you, the english readers, this looks fine. But the system is hebrew one, and the word used for “format” was, well, “format“. The developers knows that “format” in this context means “pattern”, but the ordinary user may think he should format his HD in order to correct the date!

    And the “dd/mm/yyyy” is also not in place. We, “the strange guys who know computers”, understand immeidately what it stands for, but try to ask your mother or father about it.

    You may think I'm exaggerating. Well, take a look here, and think again.

  • Who humiliates VB.NET developers?

    As some VB.NET developers found out, some methods of the Page class do not appear in the intellisense of the VS.NET. Some of this methods are: RegisterStartupScript, RegisterScriptBlock and more.

    In my old newbie days, I ignored this. “This must be a bug” I thought, and dismissed the whole issue, but as I wrote more and more ASP.NET pages, it became a really annoying little thingy. I decided to look for it a little more deeply, and what I found was quite surprising. It turns out the VS.NET has special settings for this. It is located in the Tools -> Options -> Text Editor -> Basic -> Hide advanced members, which was turned on by default. “Well, that's strange” I thought to myself, and turned it off. However, my curiosity led me to check the situation in the C# zone. To my surprise, this checkbox was turned off by default!

    What were the guys at Microsoft thinking to themself? That VB guys won't stand a method with more than 6 characters? That their brain will stop functioning when trying to grasp the so called “advanced” methods?

    I really don't know the reason for that, but I hope this does not represent the way MS think about us, the VB.NET developers.

    I hope someone from MS can respond to that, and maybe shed some light on this issue.

  • Hello World!

    Well, I guess this is the most overused opening statement, but old habits die hard...

    My name is Memi Lavi, and I am a Development Manager in EDS Israel. We're doing a lot of interesting stuff in here, most of it in .NET, but we have some projects in the four-letters-language-which-begins-with-J.

    In this blog I will share with you my thoughts about the .NET architecture, some server control staff, VS.NET issues, and some more. Hope you'll find this interesting.

    If you would like to tell me something - drop me a line!

More Posts