July 2007 - Posts
Shani Raba has tagged my to answer this question.
I think the answer is pretty simple : Don't stop learning. Read, code, and listen to the people around you. I think that curiosity is a very important thing. In the race of life, it's easy to be stuck in a rut. To wake up every morning, go to work, go home, sleep and repeat (I've been there). I don't except that anymore. You shouldn't either. Find the time to learn new things, to experiment technologies and wide your horizons. In the world of software, if stand still , you will be left behind. So be curios - it is the one thing that separates good programmers from excellent ones.
Things I want to do :
- Read : Books, blogs, articles - We've just last week got several very interesting books that I would really like to read, on every subject from design patterns, through web site advanced development, to performance in our Database. Shani gave me a simple goal - 4 books until the end of the year. I would like to accomplish this goal.
- Unitesting and TDD : This week I started to do this - with not to much success, and a lot of suffering. I would like to improve doing this - It will take time and a lot of code.
- UI and Usability : Currently my team is very bad in this subject. I've been trying to get this in the door for a long time. I'm taking this as a personal challenge. I want to learn more about how building a usable and friendly interfaces for our users, and to assimilate that in my team. In my opinion, it's the MOST important thing in an application.
- Technologies :
- Enterprise library 3.1 - I currently know only the basic, and I didn't practice it much.
- ArcSDE 9.2 new features - especially the new packages which allows you to use standard queries in order to access geographic information.
- DirectX - This is a personal one. I started with computers in order to learn to do computer graphics. Until now I haven't had the chance to learn using DirectX in order to do graphics.
- WPF - Taken the next level in UI and graphics sounds very interesting (and looks amazing...).
- C# 3.0 (Only if I get Orcas to work without crashing my computer).
- Troubleshooting : we've all been there - web.config gets checked out by TFS and no one knows way, an application locks an assembly in the GAC which prevents you from compiling and so on... So you skip these problems, find yourself a patchy solution and continue on (somebody said, remove the readonly from the web.config... :) ). So I need to start thinking at these things differently - from now on if I would stumble with an annoying problem, I will not move on until it's fixed!!!!!. I would make time in each week to try and solving them one by one.
Things I won't do :
- I won't take things for granted. When I first started in the team, I argued with every one about every thing. Every one told me I was very stubborn. I mellowed down in the meanwhile, but I still think that criticism is good - You should never take anything for granted. Not bugs, not architecture decisions, and not nonsense of VS and TFS. You have a problem with something - don't be afraid to ask about it. It is sometimes very interesting to find the answers.
- I won't stop playing computer games (although almost everyone will tell you it's for kids only). The reason I was interested with the computer, as a child, was games. In the past, in every new language I learned , the first project I did with it is to create the "Snake" game. I like to play them, and create them (EA here I come...). So no matter what happens, I will always find the time to play another level.
That's it.
Next year I'll see if this all came through.
Have a great week.
I'm tagging :
Yoav Michaeli,Nati dobkin
A couple of months ago I was performing maintenance on the main page of my team's web site. One of the things I noticed is that the page contains a disabled scroll bar which is not used. So I wanted to remove it to give more space in the page for other stuff (especially the Map - the site is a GIS site). So after a little reading in the MSDN I found that there is a CSS property which is responsible for this. It is called "overflow". The property can have these values :
- visible - If components in the page exceeds the boundaries of the container then they will simply be shown.
- hidden - Only the parts that doesn't exceeds the container's boundaries will be shown.
- auto - When the components exceeds the boundaries, a scroll bar will be shown, that will allow to scroll.
- inherit.
In the body element the default value is "auto" - which means that the vertical scroll bar will always be shown, even when it's not in use. In div elements the default is "visible".
So I changed that definition to hidden :
<body style="overflow:hidden">
And the scroll bar disappeared.
A month later we started a new project, in which I had to create a new main page. And again the unnecessary scroll bar appeared. So I tried the same thing, setting the overflow property to hidden. But the scroll bar didn't want to disappear!. I debugged again and again, but I couldn't removed it. Meanwhile the project was canceled, and I moved on to other things.
Two days ago I started to develop a new page for our current project. And again, the same problem. This time I decided I must understand why the overflow property is being ignored. I started to look for differences between the new page and the main page. After a little while I found that the DOCTYPE definition in the main page was different :
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
In the new page it was :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
What do this mean ? First, lets understand what DOCTYPE means...
DOCTYPE is an element in an HTML page which defines the DTD (Document type definition) of the page. The DTD defines the structure and format of the XML schema to which the HTML document complies with. The browser knows to look for this definition in each page, and to validate the page's structure accordingly. Then the browser ignores all the attributes and tags which didn't passed the validation. The main page, which was created a long time ago, has the default DOCTYPE of HTML 4.0. The new page , which was created in VS2005 ,had XHTML 1.0 as the DOCTYPE - this is a newer format which is more strict. So, if I replaced the DOCTYPE in the new page, the scroll bar will disappear. And it did...
But I wanted to find a more general way to do make it disappear, which is not dependant on the DOCTYPE. So I searched and found the "scroll" attribute, which can be applied to the body element :
The default of this attribute on the body is "yes". By setting it to no, the scroll bar disappeared in both cases.
This solution has two problems :
- For some reason, the designer in Visual Studio, thinks the attribute is not legal in the body element (although I checked and it is valid in XHTML 1.0 and HTML 4.0 - the proof : It works in both cases!).
- This attribute can not be changed via CSS - it's an element attribute and not a CSS attribute. It's quite problematic because I want to all the visual aspects of my page to be in a CSS file. This is a visual aspect which can only be set in the page itself.
If you can think of a better solution, I will be glad to read your thoughts.
P.S. :
While I browsed for solutions I found this site which explains about XHTML :
http://www.webmaster.org.il/guide.asp?subject=xhtml&class=introduction
Shabat Shalom (Enjoy the heat...)
In the last couple of weeks I have been learning the Asp.Net Ajax extensions and Toolkit. It really is an amazing framework for simple and complex web applications.
While I was practicing the technology, I notice that there was something missing. I couldn't update an UpdatePanel from a JavaScript in the client side.
Why this is useful ? Well, I'll give you an example : Suppose we have a web site which has multiple update panel which are needed to be updated every 5 seconds (If an update has occurred in the data they display). The simple way to do this is to add a timer control from the extensions, and add a tick event every 5 seconds. What's the problem with that ? My team leader, Doron, found this article in msdn : http://msdn.microsoft.com/msdnmag/issues/07/06/WickedCode/Default.aspx?loc=en
The article mainly deals with performance issues in the Asp.Net Ajax extensions. One of them refers to performance of the UpdatePanel. When you are using an update panel in a web page, the whole request is posted back to the server when you want to update an update panel. That means that for each tick of the timer a regular request will be posted back to the server (I remind you - every 5 seconds). Now If you have even two or three GridView control, that could be very inefficient. So the solution is to create a java script timer which every 5 seconds calls a WebMethod from a web service, which checks if the data has been updated, and then the client needs to trigger a post back of the particular update panel - which contains that data.
So how to I trigger an update in an UpdatePanel in the client side ?
At first I thought to create my own UpdatePanel which inherits from the original. But that could be problematic - especially with existing web forms - I would need to replace all the panel with my own - not to mention problems with embedded resource in the original assembly that contains the UpdatePanel control.
So I decided to create an extender for the update panel which adds an "update" method to it's panel. Here's an example of how it should be used :
<script language="javascript" type="text/javascript">
// <!CDATA[
function Button1_onclick() {
var u = $get('<%= UpdatePanel1.ClientID %>');
u.update();
}
// ]]>
</script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
<ysa:UpdatePanelExtender ID="UpdatePanelExtender1" runat="server"
OnUpdated="UpdatePanelExtender1_Updated" TargetControlID="UpdatePanel1">
</ysa:UpdatePanelExtender>
<input id="Button1" type="button" value="Client Button" onclick="return Button1_onclick()" />
I created the extender using the extensibility infrastructure of the AjaxControlToolkit. An extender contains three parts :
- Class which inherits from ExtenderControlBase - which contains the server side code.
- Behavior : a JavaScript object which contains the client side code.
- Designer : optional - contains a definition of a designer for the extender.
To learn how to create an extender click here.
In the UpdatePanelExtender (catchy name...) I simply added a hidden button to the update panel :
protected override void CreateChildControls()
{
// Adding the button that will be used to trigger the update :
Button updateButton = CreateUpdateButton();
TargetUpdatePanel.ContentTemplateContainer.Controls.Add(updateButton);
// In case the target panel defines that the child controls can not trigger a postback, add the update button click event
// to the triggers collection :
if (!TargetUpdatePanel.ChildrenAsTriggers)
{
AddUpdateButtonAsTrigger(updateButton);
}
UpdateButton = updateButton;
base.CreateChildControls();
}
private Button CreateUpdateButton()
{
Button updateButton = new Button();
updateButton.Style["display"] = "none";
updateButton.Text = ClientID + "_UpdateButton";
updateButton.Click += new EventHandler(UpdateButton_Click);
updateButton.ID = ClientID + "_UpdateButton";
return updateButton;
}
private void AddUpdateButtonAsTrigger(Button updateButton)
{
AsyncPostBackTrigger t = new AsyncPostBackTrigger();
t.ControlID = updateButton.ClientID;
t.EventName = "Click";
TargetUpdatePanel.Triggers.Add(t);
}
In the initialization of the extender's behavior, I added a method to the UpdatePanel which is called update :
initialize : function() {
YsA.Web.UI.WebControls.UpdatePanelBehavior.callBaseMethod(this, 'initialize');
// Adding the update method to the update panel :
var e = this.get_element();
e.update = Function.createDelegate(this,this.update);
}
The update method simply calls the "click" method in the button control :
update : function() {
var updateButton = $get(this._updateButtonClientID);
updateButton.click();
}
(_updateButtonClientID is a property that is initialized by the extender which contains the ID of the update button).
That's about it.
A solution which contains the source code and an example web form is attached to this post.
Known issues :
- I tried to create an event in the extender which will be triggered after the panel updates. I couldn't make it work. The final revision is in the source code - check it out. Maybe you could tell me what I did wrong.
I will be glad to read your comments, bugs you found, and improvement suggestions.
Have a great week.
Update :
I've updated the extender. The updated version is in the UpdatePanelExtender Upgrade post. I've also removed the old version from this post.
In the last couple of weeks I've formatted and reinstalled my laptop. It was one of the longest installation I've ever done and I encountered many problems during the installation. This was a really annoying one.
After I finished the installation of windows, updated it, installed visual studio, and updated it also, I created a simple web-site to see that everything is working properly. When I browsed the site I received the this error :
"Failed to access IIS metabase
The process account used to run ASP.NET must have read access to the IIS metabase (e.g. IIS://servername/W3SVC). For information on modifying metabase permissions, please see http://support.microsoft.com/?kbid=267904."
Apparently a very good error description, so I entered the link and started to read. I must say, this was a complicated article about missing ACLs (Access Control List ) that are necessary for accessing to the IIS. A script was supplied in order to create them. Pretty nice. Shame it DOESN'T WORK!!!
After a couple of hours of various attempts to make it work, I decided it's Google time! A quick search reveled the simplest solution : Reinstall the .Net framework redistributable. I asked my self Why??? After all I had an installation of windows XP SP2 which comes with the framework built in... So I decided to dig a little more and found the problem :
Windows XP SP2 installation is secure by default. That means that IIS is not installed in the default installation. So after you install you must add it in the Add/Remove windows components in the control panel. What I didn't know is that the .Net framework installation registers the framework in the IIS. The registration is preformed with the command : "aspnet_regiis" which is located in "C:\Windows\Microsoft.NET\Framework\v2.0.50727\".
This command performs many configurations in the IIS and in the operating system. One of them is to create the ACLs which grants the user which runs the Asp.net process to access the IIS metabase and other folders that asp.net needs in order to run properly. Another one is to apply the version of Asp.net on the web sites under the IIS (You can see the version under which your web site runs in the Asp.Net tab in the properties of your web site in the IIS administration tool).
So what happened ? I installed the IIS AFTER I installed the .Net framework which means that the aspnet_regiis command didn't run.
How do you fix this ? Simple. Run the following command in your favorite command window :
"C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -i" (The -i switch indicates that you want to register the framework in IIS).
Have fun, and remember : Google is the greatest! :)