# Monday, August 31, 2009
Sometimes you need a control over browser window behaviour, i.e. open a new one and close it, eventually.

This is really simple. All you need to write is one liner code.

To open an window:
window.open ("http://www.google.com","window"); 
Then you can close it by:
window.close();
In ASP.NET you have variety of ways to achieve browser window close. One example:
closeButton.Attributes.Add("onclick", "window.close();")
By this, close functionality is dynamic added to the control event.

Important: you can close a browser window with code which was open by the code.

However, this open/close window java script technique is more or less obsolete. If you need to display a special "window" to the user, you should use modal windows. ASP.NET AJAX have a nice control, called "ModalPopup".

posted on Monday, August 31, 2009 7:24:45 AM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Saturday, August 08, 2009
I have implemented a very simple validation site. You just put an XML and XSD to it and it tells you if your XML document is valid. Simple.

Just vist XML Validation site and try your XML against XSD. Please notice that it is version 0.01 so I presume you know what that means. :)

When and if it will be updated is depended on the planet polarization.


Related:
http://blog.stegnar.com/2009/06/03/SimpleXMLValidationWithNET35.aspx

posted on Saturday, August 08, 2009 9:30:32 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Monday, May 11, 2009
Most application need some kind of localization, really. Today I will represent one simple possible solution for this in ASP.NET.

This localization is based on .NET resources (.resx). As name tells us resource is, well (re)source of something, typically strings. So as it looks like this resource file seems like perfect for our localization problem.

Resource file is XML base file type, it looks like this:


It also exist a resource editor, where you can easily edit resources:



Let's say our web application need localization support for two languages, English (default) and Slovene. First we create resource file for each supported language and for default one. So we create something like that:


Here we have a default support language (English) and other supported languages (for our case Slovene). You have to be careful with naming - naming convention is resource_name.[language code].resx.

And to the best part - code. All you have to is to set a CultureInfo to a current thread, and ASP.NET will automatically resolve a proper resource file. You can set in in your ASP.NET application file (Global.asax) like:
 System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(cultureName);
Well, you a done, with localization of you application!

All is left is an actual use of it. Here you have one example:
 <asp:Literal runat="server" Text="<%$ Resources:Resource, strForm1Hello %>"/>
You can see I use build-in ASP.NET functionallity of resource reading instead of hard-coded string. Which is anyway good practice not to have it.


posted on Monday, May 11, 2009 7:59:23 AM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Saturday, May 09, 2009
Yesterday I was debugging an ASP.NET application based on database (MS SQL Server). I was getting a strange error:
EXECUTE permission denied on object 'sp_sdidebug', database 'master', owner 'dbo'.
Well store procedure 'sp_sdidebug', enable debugging on SQL Server. Since this SP is in "master" database, you have to have proper access and execute rights on this master DB.

posted on Saturday, May 09, 2009 8:41:15 AM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Friday, May 08, 2009
One of the most basic action in web development is redirecting. Redirecting basically mean that browser show other resource URL than was requested. This is useful to enhance usability and to achieve control over user request. There exist two levels of redirecting. First level is on IIS server named "Default content page", you can enable it to order an IIS server to automatically redirect request to specified resources.

Second level of redirecting can exist in your code. All you have to do is to use a Response.Redirect(string url) directive. This directive orders a client (web browser), that requested resource was moved.
HTTP 1.0 302 Object Moved 
Location
www.domain.com
Then browser do request again with given URL.

posted on Friday, May 08, 2009 1:23:39 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback