January 2006 - Posts
Got a problem while upgrading to Norton Internet Security 2006. not happened to every computer but did happen in one of my case.
After installed Norton Internet Security 2006, when doing a Microsoft Update (online) , there might be "0x80072EFD" error occured and not able to connect to the service.
A search to Google find this site that's helpful. basically this should be caused by that NIS 2006 defaultly blocked 443 port connection. (seems Microsoft Update used port 443 for communication). after permitting the port access, the problem was solved.
This is not happened everytime. but might happen if one switched the network configuration and NIS 2006 didn't notice to create a new location for it (eg. only change a gateway or something minor). but if this happened. the problem above is possiblely able to occur.
To check if this is the cause of reason not able to do a Microsoft Update, first turn off NIS 2006 firewall and see if this still happens. if it did happen after disabled firewall, then it might be the internet connection problems that cause this issue. If firewall is disabled and Microsoft Update site is back to normal, then it might be the cause described above.
Technorati Tags: microsoft , norton, firewall
Cost me hours to find this! thanks to the person who posted to Channel9!
Just got Hitachi 7K100 (2.5" HDD, 100GB, 8MB buffer, 7200rpm) and was going to reinstall my host OS on my notebook those 2 days.
after installing XP SP2 and started to install applications and tools, happened after several installations, IE6 just started freezing when trying to download and save files from internet. the download dialog just freeze before pop-up the file-location dialog box for user to choose.
I was originally thinking that maybe some of the installed programs corrupted IE6, so just un-install programs step-by-step reversely to see if IE6 will go back to normal. after several un-installations, all in vain!
later found the post at Channel9 that specify the problem of the cause! really thanks!!!
[via Channel9 Wiki]
Download File Dialog freezes
When the last location you saved to was a network path (eg. \\fileserver\myhomedir) the Download File dialog freezes (IE6SP2). This can be fixed by changing HKCU\Software\Microsoft\Internet Explorer\Download Directory to a local path. This happens to me often after working over a VPN.
This is exactly what happened to me!! after I checked that registry, exactly a network sharing directory on the record. that explain the reason why the download dialog will freeze there, cause the application was trying to locate that sharing directory.
After change the registry entry to a local path, everything back to normal!!! So I have to re-install all the programs that's been un-installed couple hours ago... Orz...
Technorati Tags: microsoft , internet explorer, bug
just a reminder of forming a sql query.
for concating strings in different databases, refer to my post here.
for concatenation, MS SQL uses " + " operator , Oracle uses " || " operator (as well as MySql uses function CONCAT() ) . so if one is designing a Data Repository using Repository Pattern, one may need to process this in repository level, which like providing a function for other code to concate strings in forming a query.
fortunately, for escaping single quotation mark in a query , it's the same as in MsSql and Oracle , they both used 2 single quotation marks to escape single quotation mark in a single-quotation-mark quoted string. (eg: for a string like o'connell to put in a query, it's 'o''connell' , " ' ' " is escaped and represents " ' ").
by the way, as NHibernate is just transforming object propertires in to real database field names, those rules above also apply to HQL query. also true if one is using escape chars in a "like" search (eg: select .. from class1 cls where cls.prop1 like '%My\\_Name%' escape '\\' ), the translation to real sql query both for mssql and oracle is tested without problems.
Technorati Tags: hibernate , nhibernate , orm , database , programming
When one is writing client functions, and needs to attach to event handlers, like:
<input type="button" name="aName" id="aID" value="Press Me!" onclick=" func1(); ">
It's simple when just calling a function to do things. Alternatively, one can also write multiple statements inside the onclick string:
onclick=" var str1='a string'; alert(str1); "
What about if one is going to dynamically generate a control (via string) and put it in some other controls innerHTML, like this:
var strshowmsg = "Show me as a string";
var strtrouble = "Show me as a string with \" exist also got ' exist!!!";
var strcontrol1 = "<input type=\"button\" id=\"button1\" name=\"button1\" value=\"Press Me!\" onclick=\"var str1='" + strshowmsg + "'; alert(str1);\">";
document.getElementById(strASpanTagID).innerHTML = strcontrol1;
It should be ok if the first string is going to output, but it should got script error when trying to show the second string because quotation marks crash pairing of strings.
strtrouble string variable often happened when strings are coming from a database or some user input. one never know what will be coming in (except telling user that only single quotation marks are allowed or what). in order to allow anything to be able to put in this kind of application, there is one way to do it.
var strcontrol1 = "<input type=\"button\" id=\"button1\" name=\"button1\" value=\"Press Me!\" onclick=\"eval(unescape('" + escape("var str1=\"" + strshowmsg.replace("\"","\\\"") + "\"; alert(str1);") + "'));\">";
just got auto-update notice this morning that MSN Messenger had a minor patch to 7.5.0322 ,
also there is Mess.Be Patch for 7.5.0322 available to download.
People will need this Mess.Be Patch to remove the ad banner also enable multiple accounts login, also some other tweaks...
Technorati Tags: msn , messenger
busy on writing my code and get this "failure occurred while attempting to start compilation" from vs.net 2003 , happened without a reason.
a search to Google found the reason of the cause (likely) [I am not lonely... Orz]. Seems too many projects in one solution will cause this error (I got 17 projects in a solution currently). some one got 67 projects provided a fix to solve this (thanks to Jeffrey to point out the link), but didn't work out to my situation (close vs.net, delete all pdb file by using "del *.pdb /s", open vs.net and compile again) .
Finally I got my situation solved by:
Minimize projects in a solution to 13 projects.
Close VS.NET 2003
Delete all .pdb files in bin dir.
Delete all .dll files in bin dir.
Open VS.NET 2003 and compile again.
I know! this will be my last project using VS.NET 2003, will switch to VS.NET 2005 in next project.
... Or I know!! I'll start learning using NAnt..
Technorati Tags: asp.net , programming, visualstudio
The follow-up of my company's SORB database issue (here and here).
I've asked my ISP to manually extend our company's rDNS record TTL to 86400 and now it passed the test from SORBS database.
just did a test trying to excluding the IP from the database and still get rejected. reason:
Checking MX's for xxx.com...
Rejecting MX 10 [TTL 13135] mail.xxx.com. (TTL too short)
No acceptable MX records found for wislite.com.
SORBS really did seriously checking to a dynamic IP !!! Orz
How to manually set DNS records TTL? by refering articles here and here:
; MX record Format:
; name ttl class rr pref name
example.com. IN MX 10 mail.example.com.
; A record Format:
; name ttl class rr ip
joe IN A 192.168.254.3
$TTL 2d ; zone default = 2 days or 172800 seconds
just set ttl time between name and class will do. or just set default TTL for the whole domain.
Technorati Tags: email , smtp , sorbs , rdns , hinet , reverse dns
It's mostly required to do the initial values validation while an application start, no matter it's a winform or webform, a page taking values from query string or a web control taking values from attributes.
It's common for page to take parameters from query string during post backs, also normal for web user control to get parameters from attributes specified from page or other controls. It would be a good practice to always validate those values before start processing logics.
for parameters there will always some values (mostly string values) pre-defined for user to specify. normally some integers, or strings like "true" or "false" or others custimized. by doing a initial value validation while page_init make sure the control gor the correct value and reduce the error handling inside logics. normally the validation code would like the following:
if (strValue1 == null) strValue1 = ""; // be sure always check null.
if (strValue1.ToLower() != "true" && strValue1.ToLower() != "false") strValue1 = "false";
if (strLevel == null) strLevel = "";
if (strLevel.ToLower() != "low" && strLevel.ToLower() != "middle" && strLevel.ToLower() != "high") strLevel = "middle";
this will get little lousy if a parameter got too many options to set.
null is always the thing needs to be checked, since one may not able to know if certain variable was initialized or not. make sure at least the string is not null, then for those lousy if statement, just found a way to reduce it, by using string comparison:
if (strLevel == null) strLevel = ""; // make sure it's not null to prevent runtime error
if ("_low,middle,high".IndexOf(strLevel.ToLower()) < 1) strLevel = "middle";
if (strValue2 == null) strValue2 = "";
if ("_1_2_3_4_5_6_".IndexOf(strValue2) < 1) strValue2 = "1"; // check if the value is 1~6.
using IndexOf to check the occurence of preferred values, reduce the if (...) ...; code needed. some notices of this are:
strLevel can not be null or it will cause run-time error. so check the null first.
Astring.IndexOf("") always return 0, which make sense anyway. this will be the same index value of first char of the string to be compared. therefore do not put comparing string from first position. instead, putting them started from the second char by putting a space or anything in the first char. and do the compared value that's " < 1 " instead of " < 0" .
for the concern of matching the wrong value wanted, eg intened to matching "1" inside the string "_123456" , but a value "12" comes in, it will match ( index at 1 ) but still got the wrong value required. put seperators between matching values should solve this (eg "_1_2_3_4_5_6_").
RegularExpression class should be the right one to choose for this operation, but it still seems too lousy to me.
this should reduce some amount of coding, also easy to understand the intension. and page or control will got correct and required values while processing logics thus reduce validation code needed.
Technorati Tags: asp.net , programming
Google search got many result about this, since it's already old tricks that's often used in many websites. but sometimes it's easy to forget about how to quickly write one in hand, I found this example that's simple and quick to understand and pick up.
Since I am not in a Unix / Linux world (yet) , gotta find my own way and tools to deal with such problems, in a windows way.
Situation as follows:
I kept a source tree in my own development VM to keep source integrated and shared between my team members, in a local LAN, mostly at on-site environment that might block various internet access ports (SSH, port 22, etc). That means I am managing a CVS server in my development VM and team members just submit code they modified and also update code others submitted (make sure you are using secure protocols to send your source around network).
There is the main source CVS repository in my company office, in some situations the customer site may also got a source tree for vendors to submit into. so there will be problems syncing the local cvs source tree (in my VM) and external source tree (main office or customer site).
Since "CVS" folders should not be touched while sync (contain version information to compare with), and the destination (main office, etc) may contain files that already deleted that need to clear, there should be something that need to be careful in order to prevent massing up my updated source which might spend couple days developed.
A quick way to should be just using WinCVS to change the CVSRoot of master local copy from local to the destination, then just do a update->add content->commit to update the destination. but I do think that is too risky cause a miss could mass up my local copy no matter it's the miss made by myself or by any CVS client.
So I am developing my own safer way. comparing files myself using tools. my solution as follows:
First create a temp directory, checking out local copies both from local cvs repository and the destination cvs one (either using WinCVS or TortoiseCVS, I found it easier using TortoiseCVS), so I got 2 directories with different CVS meta info (the CVS folders contains different info for 2 cvs resposotories). next, using a batch file xcopy with exclude options to xcopy all the things from checked-out-ed local copy to destination one, EXCLUDING all CVS folders. now I got identical files in both directories without affecting cvs meta data. the latest thing should be remove deleted files in destination. for this I used WinMerge to help me. WinMerge not only help A LOT on comparing conflict source files, but also capable to compare 2 directories with all the differences. check WinMerge website for usage and you'll know what I am talking about. it also integrated very well with TortoiseCVS. so I can use WinMerge to find those files that I was deleted in local but still left in the destination. then it's easy for destination local copy to just do a remove of those files, and finally, an add content -> update -> commit should check-in all the source to destination cvs repository that's identically the same as my local source tree, without affecting my real working source.
I shall try out using a SubVersion repository in my next project.
Technorati Tags: windows , cvs , cvsnt
a = ( b / c ) | 0
by using a bitwise OR operation to cast a float / double back to an integer, to have a way casting some numeric values back to desired form.
It's a minor but annoying problem for CommunityServer 1.1 . solved couple weeks ago.
the recourse file used is English resource file, located in /communityserver-website/Languages/en-US/Resources.xml , there is a resource at line 2482 like this:
<resource name = "ManageLinks_ConfirmDeleteCategory">Are you sure you want to delete this category? All of it's child links will be deleted as well.</resource>
the code that cause error is at the category delete button onclick event. which is like this:
onclick="return confirm('Are you sure you want to delete this category? All of it's child links will be deleted as well.');"
as obviously, that is the "it's" inside the " ' " string that caused the error, which is the resource string above.
to solve this, just remove the " ' " of that "it's" to "its" or some other things that don't have a " ' " inside, then it's done, no source code modification is needed.
A mirror post to CommunityServer Forum about this issue is posted at http://communityserver.org/forums/508956/ShowThread.aspx#508956 . hope this helps...
Technorati Tags: communityserver , asp.net , programming
It's always inspiring reading msdn blogs, be sure you got the rss feed of them!
[via Robert Burke]
How do you maintain page scroll position after a postback?
Say you've got some really long page, perhaps with some huge Control -- like, say, a huge, edit-enabled GridView. Someone clicks a link halfway down that page (like, say, the "Edit" link on one of the later entries in that huge GridView). It generates a postback, and the page get refreshed to its *top* instead of half-way down.
If you want, instead, to maintain the page scroll on a postback, just set the MaintainScrollPositionOnPostback property on the Page. You can do this declaratively (in your aspx Page directive) like so:
<%@ Page MaintainScrollPositionOnPostback="true" ... %>
If that's too heavy-handed a solution (i.e. you don't want to maintain scroll position for all postbacks), you can use the solution found on this page.
Technorati Tags: asp.net , programming
I was dealing a general purpose web user control (ascx) with Ajax functionalities and may be used many times in a single aspx page.
Something may have duplicated client IDs or Names:
- pure HTML tags (self-written span tags, div tags, input tags, etc to hold data dynamically)
for duplicated html tags, it can be corrected by putting the ascx contrl name prefixed, just like what asp.net did for server side controls. by using a <%=this.ClientID%> prefixed in html tag id attribute, self-written html tags can then be distinguished in the same page if multiple same controls were loaded into.
Chris' code will override RegisterClientScriptBlock function provided by Page class to automatically put script tag (<script ...> ... </script>) for the scripts passing into the function. it's nice to avoid layout error if user forgot to put the script tag for scripts, but it will also cause errors if the scripts passing into already got script tags inside. as it's an overrided function for page class, other controls in this derived page that using RegisterClientScriptBlock function to register client scripts will also be affected and causes multiple script tag parse error. to avoid this, it's better to modify the overrided RegisterClientScriptBlock function provided by Chris to add a check to see if there was already script tag inside the passing script string. I did encounter this problem since in the control I used Ajax.Net objects and it automatically register its own client scripts using this approach.
for duplicated global sharing variables, there are still 2 ways to resolve this problem. one is just like what asp.net did for server controls, adding this.ClientID prefix at each variable name, and then for function calls passing each necessary global variables in for processing. this would not be a good way since first of all the client side variables will be full of server side tags just like in old asp time, and second if there were lots of global sharing variables to pass into functions it would be a lousy function signature and considered as a bad practice.
the other way to work around this is to wrap all the global variables into a single array or object. using array got its weakness that using index to get certain variable requires knowledge of array layout structure. using object with properties for global variables would be a better way to do since it can achieve sort of "strong type" style and variables can be retrived by exactly the same global variable name without prefixing with this.ClientID (the only variable need to use this.ClientID to distinguish between multiple same controls is this main object that hold those global variables as properties!), which is good for code reading and preventing indexing wrong stuffs while using array approach.
for consolidating all client side global variables in a ascx control, it's good to use JSON syntax to fast organize them into a single useful object to be passed around all shared functions. for JSON stuffs refer to Steve Maine's post about JSON to get a more detail understanding about this.
Conclusions until here:
- using this.ClientID server tag to prefix self-written client html tags
- rewritten sharing functions for each ascx control which will potentially be used multiple times in the same page.
- using Chris Maunder's customized RegisterClientScriptBlock function to settle down client functions without duplication.
- using JSON to organize sharing client global variables into a single parameter object for easy function paramater passing.
one more trick to mention, for those sharing client functions, it's good to put them all into a single .js file and using Chris's RegisterClientScriptFile method to form a script tag with src attribute indicating the location of the .js file for the including. furthermore, if it is necessary to "dynamically" load different client functions based on different ascx control usage (eg: one ascx generic control with parameter that specifying using different user input like a dropdownlist or checkbox or listbox or radio button to layout an ajax output variable set, it may require different sharing functions regarding dealing different user input type interaction!), it would be good to change .js file into a .aspx file and passing querystring parameters and then using server side tags to do conditional selection of functions to output (still old asp tricks). this will make the final client page layout more neat and elegant...
[Updated 2006/01/05 19:44]
Cautions when using Chris' solution to put all the client scripts in the same location! I was just encounted an issue that may not fit into Chris' approach.
By using Chris' approach he was using derived page's OnPreRender() event trigger to output all the scripts registered using overrided RegisterClientScriptBlock function. this shall successfully capture all the client scripts registrations without problem. BUT! something may be missing!
for a page contained many controls inside it, if all the sub-controls (including custom ones) all register its client script before it's OnPreRender() event trigger, which should be like at Page_Load(), or Page_Init(), etc, then everything should work out just fine.
according to what was stated in msdn help about RegisterClientScriptBlock function, this function allowed users to call it from anywhere around the code-behind life cycle, therefore if some controls using this function after PreRender event during the dynamic layout rendering time, then Chris' function won't be able to layout those later-added client scripts, although my test showed that the overrided function did successfully captured those later client script blocks, but since it's already passed the PreRender event, there won't be other time to really render those latter happened scripts, thus finally results missing of client script blocks.
I am wondering how asp.net's own page class processing this function that can get regiester client scripts everywhere during the code-behind life cycle and in the latest just rendering all of then in the place that's right behind the form tag, amazing...
Technorati Tags: asp.net , programming , ajax , ajax.net , json
I got the xml serialization tips post before. today I just found that the serialization won't work again. later found that it's cause by the encoding. seems the output string is back to utf-16 encoding and XML DOM's LoadXml() function won't be able to parse it and just throw an exception saying that the syntax is wrong at the very first char, although the whole node structure were right.
couple articles found very useful after a search to Google:
- Shawn Steele's post "Avoid treating binary data as a String" talking about it should be careful converting between byte and string. this might affect my working since I am dealing with Traditional Chinese encoding in unicode.
- Roy Osherove's post had comments of code samples about how to let StringWriter class be able to specify Encoding (originally read only).
- Finally, Robert McLaws's post with comment thread featured XmlWriter PM Joshua Allen's explanation of string encoding and XmlWriter behaviors, very nice an article to clarify many topics faced around encoding and xml serialization in .net framework.
I'll still use MemoryStream to store utf-8 encoding during serialization, but I'll use Joshua's code sample to output the string instead of using MemoryStream.ToArray() stated in links found in my xml serialization tips post.
My project code is back to work as it should be after the code modification, but I shall do more test about it to see if Traditional Chinese chars in serialized xml string will make XML DOM object not able to load again. will keep an eye on it while testing phase.
Technorati Tags: c# , dotnet , programming ,xml , serialization , unicode , encoding
More Posts Next page »