Wednesday, May 30, 2007

ASP.NET File Upload

Yesterday I had some problems with uploading files in ASP.NET. I've did this maybe thousand times before in PHP, CGI and some other systems, but now, it simply didn't worked.

I have used the classical FileUpload control, selected the file, pushed the button, but after Postback, the Request.Files variable has been entirely clean.

Form encoding was fine, generated HTML code looked ok. After some digging I found the ground of this problem. The FileUpload control has been placed in AJAX Update panel. After clicking the upload button, the panel (not the browser itself) tryied to send this request. And probably didn't knew how to send the file.

Placing the FileUpload outside of the UpdatePanel solved this issue. There is some kind of a workaround in this forum, but I hadn't enough time to test it. Maybe next time.

Sunday, May 20, 2007

RCP Keybinding Issues

Currently I'm developing some RCP application (using Eclipse 3.2 and 3.3M6) and I noticed, that some keyboard shortcuts aren't working well.

By the way - sometimes it seems to me, that there must exists one secret URL containing complete and actual RCP documentation, which every developer - except me - knows.

Back to the problem - we were using older way (deprecated, but still functional) to specify key bindings in plugin.xml

<keyBinding
commandId="yournamespace.command.newempty"
keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
keySequence="Ctrl+N" />


It works fine, but not for keys, that are normaly used by RCP (common shortcuts like Ctrl+N, Ctrl+S, etc.). This combinations needs to override (of course, you can implement the corresponding actions, but sometimes you may don't want to do that) the default RCP setting, but how?

The way I found is as follows:
1. Create some context for your app in plugin.xml:

<extension point="org.eclipse.ui.contexts">
<context id="yournamespace.context" name="Default Context"
parentid="org.eclipse.ui.contexts.window"
description="..."></extension>


2. Move problematic keybindings into this context (by specifying contextId in the keyBinding element):

<keyBinding
commandId="yournamespace.command.newempty"
keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="yournamespace.context"
keySequence="Ctrl+N" />


3. Active this context at run-time somewhere in the app init:

PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
((IContextService) PlatformUI.getWorkbench()
.getService(IContextService.class))
.activateContext("yournamespace.context");
}
});


That's all folks. I suppose the command you have specified in commandId already exists (if not, create it). The same stands for action binded to this command.

Actually, not all actions are always specified in plugin.xml, but are created at runtime. Wiring this action (to command and its keybinding) through following methods worked for me.

undoAction.setId("yournamespace.action.undo");
undoAction.setActionDefinitionId("yournamespace.command.undo");
this.getActionBarConfigurer().registerGlobalAction(undoAction);

Hope this post might have helped someone. The presented solution isn't very clean, but functional for me. If you have something better, please feel free to post it here.

Sunday, May 13, 2007

IE Troubles

I don't like Internet Explorer. Nothing special now - if you don't like it, simply don't use it. Right, I'm using Firefox for quite a long time. But sometimes I need IE for a little while (actually I use IE Tab, but that's completely different story).

But IE 6 started to make troubles (and it's really good in that). Every time I launched it, IE disappeared (after showing its main window for a second). So, my first guess was some kind of malware (although using IE only at safe pages and never had this problem with Firefox, just wanted to be sure). Scanned the system with Spybot, but nothing special.

Spent some time googling, again nothing special. Later I found some workaround - started explorer.exe ("This computer"), typed URL there, and the IE launched well.

This worked for a week or two. Finally I decided to update to IE 7. When Microsoft spent so long time developing this thing, it should be better than the old one. Well, IE7 worked for a week or two, then the same problem appeared.

My last solution (for last week or two :)) is as follows:
  1. Go to your Internet Options (Start, Control Panel, Internet Options)
  2. Tab Programs
  3. Button Manage add-ons
  4. Check all add-ons on this page. The one that was causing problems to me was called SSVHelper Class (published by Sun Microsystems, Inc.). So I disabled it and everything is fine since then.

Maybe that your case is slightly different, so you may try disabling all add ons and trying to launch IE. Then enabling one per try you should be able to figure out the "bad one".

Monday, May 7, 2007

Problems with D-Link DI-524

Today I bougth new router D-Link DI-524 (see d-link.de or dlink.com). I'm posting also link to germany website, because there are maybe five revision of this hardware (A to E) and the revision sold in Czech Republic (namely here) is the revision B4. Global website (well, precisely said, the US website) contains info only about the other revisions. So, the latest firmware for rev. B I have found, is here.

First, let me explain, why I wanted to flash the firmware. Because I wanted to lower the antenna transmit power - I have the router next to my computer, near my head and I'm quite sensitive to this waves. Also I don't want my neighbours to try to hack it. The emulator of DI-524, which is available on the D-Link site has this feature. Well, I was quite surprised, when this was the only feature missing in my revision (in comparison to the emulator). So I thougth, that upgrade could make it.

Unfortunately, the actual firmware in my device was 2.04, and the newest on the net is only 2.05b02. And there is no changelog. Well, I tried (with a lot of hope in my hearth) it, but after regular upgrade (everythink went well), the router stopped responding. I could not connect to the webadmin (192.168.0.1), nor ping this ip. Hard or soft reset (holding the reset button down for 10 seconds with or without power on) didn't helped. Interesting thing was, that the inner switch still worked.

The status led flashed very quickly (according to some sites, they say it's the normal - ready - state. According to me, it's some kind of failure. The normal state is, when the led blinks - say - once per second).

I was afraid, that my new D-Link DI-524 is dead. Luckily, I have found this recommendations.
Shortly: If you are having troubles upgrading your firmware (crashed router or st.), try this:
  1. Connect your PC through LAN to your router (only your PC, nothing else).
  2. On your PC, set IP adress 192.168.123.253 (thx Borge for correcting this typo), mask 255.255.255.0, Gateway and DNS to 192.168.123.254
  3. Reboot your PC (maybe optional)
  4. Use the flash utility (can be downloaded bundled with the firmware from forementioned sites) to force some version of firmware (maybe some older one) to your router
  5. Wait for some while, until upgrade process finishies
  6. Disconnect your router from power source for a minute
  7. Reboot your PC (maybe optional)

Yipee! This worked for me. On the second try, also the newer firmware (2.05) worked.

But, the transmit rate settings was still missing. Then I googled this.

It seems, that the router has some secret settings (or I missed something :)), where you can find some useful things. There are many I don't understand at all, bud there ore some I know. Yes, including the antenna transmit rate. The pages with settings can be found under following URLs (replace the IP address with yours)

http://192.168.0.1/wlape.htm
http://192.168.0.1/extra.htm
http://192.168.0.1/rtab.htm

I have used the first one and lowered the antenna transmit power to 13%. Saved, rebooted, everything went ok. According to my girlfriends notebook (and my subjective feelings) it realy worked.

Sorry for my english, and don't forget - everything you get here, is without any warranty or liability ;). Do it on your risk.

Be welcomed

Wow, this is my first blog post ever. Well, sorry for my english.

I'm planning to use this blog mainly as a storage for those little IT problems (and some nifty solutions, I hope) I meet sometimes in my life. So, don't be frustrated if there will be only a few posts per month. We'll see.

Maybe you know this situation - some ugly HW/SW makes troubles. You're trying to solve it. Then you spend a few hours on it and then ... yupii, the solution is here. Half a year later, the problem is back and you cannot recall yourself, what have you done. So I hope, that if I write the solution down to this blog, I will be able to find it a reuse it. I'll be glad, if this blog will be useful to someone else.

Also, please feel free to post any comments. So, be welcomed and ... sorry for my english.