Moses' Blog

Living {.net} lifestyle

Away Notice

I'll be away for the next 19 days starting from 30th Sept. I have no internet connection during this period.

Muhammad Mosa

Moses' profile picture
Logo
Software Engineer.
MCT, MCSD.NET,
MCTS: .Net 2.0 Web, Windows, Distributed Applications
MCTS: .Net 3.5 WF Application Development
MCTS: WSS 3.0, MOSS 2007 Configuration & App Dev
MCPD: Enterprise Application Developer

Send mail My Live Space Moses on Facebook Twitter Moses on Technorati

Sponsors



Calendar

<<  October 2008  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

Recent Comments

Comment RSS

Community Credit

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Localization\Globalization Considerations and Tips

I've been worked with localization and globalization for a while now. During that period I faced issues and learned many things about the subject. Here I am going to share some of my own ideas and tips to avoid falling in certain issues. It worth to mention that I am talking from GUI point of view and not Application Data point of view.

Consider using Resource Files ".resx" or Database:

Well this is a matter of your needs. But I highly recommends to always consider ASP.NET Resource Provider. Then it doesn't matter to work with ".resx" of Database. By default ASP.NET has a provider for XML based resources which is resource files ".resx" But also you can get a great Database Resource Provider for free from here.

Actually to choose between both you should think about that all your UI localizable terms should be stored in one central location. I mean, do not put some in resource file and some other in Database. Like you define labels on resource files and grid headers in database!! or maybe error or information messages. Just build it right from the beginning and define one central location.

More...

Posted: Sep 18 2008, 21:30 by mosessaur | Comments (3) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: ASP.NET | Tips
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

Applying localization From MasterPages

The scenario here is I want to apply localization to my web application and place language selection on MasterPage. I have made my own solution and applied this with assistance of cookies. View demo.

I'll demonstrate that in my sample. The sample has a MasterPage bellow is a snippet from its ASPX code:

   1: <form id="form1" runat="server">
   2:     <div>
   3:         <asp:DropDownList ID="cmbCulture" runat="server" AutoPostBack="True" 
   4:             OnSelectedIndexChanged="cmbCulture_SelectedIndexChanged">
   5:             <asp:ListItem Value="en-US">English</asp:ListItem>
   6:             <asp:ListItem Value="ar-EG">Arabic</asp:ListItem>
   7:             <asp:ListItem Value="de-DE">German</asp:ListItem>
   8:         </asp:DropDownList>        
   9:         <asp:ContentPlaceHolder ID="cph" runat="server"/>
  10:     </div>
  11: </form>

Simply when the user selects his language from the DropDownList the page post backs and change the language. More...

Posted: Feb 19 2008, 00:06 by mosessaur | Comments (9) RSS comment feed |
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: ASP.NET | Tips
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

WebResourceAttribute And VB.NET, Not Like in C#!

Refering to my previous post "Working with System.Web.UI.WebResourceAttribute". During surfing in ASP.NET forums I noticed a question about this issue! and in the question it is mentioned that the way I descriped didn't work. I noticed also that the guy was using VB.NET not C# on which I was working on!!

The deference, or the issue came up because C# & VB.Net treat or compile resources in deferent ways -this is my own observation-. Return to the issue post on ASP.NET Forums to know what was exactly the problemand how it was resolved.

kick it on DotNetKicks.com

Posted: Feb 17 2008, 23:53 by mosessaur | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: ASP.NET | Tips | Visual Studio
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

Working with System.Web.UI.WebResourceAttribute

You may've heared about new ASP.NET 2.0 System.Web.UI.WebResourceAttribute class. It defines the metadata attribute that enables an embedded resource in an assembly. It is valid only when used on assembly declarations and it is used to enable a specified embedded resource in an assembly for use as a Web resource.

For example, suppose you are building a web server control, or custom HttpHandler that would render some javascript "js" files and may few images etc...
Where you would store these files "resources"?! The answer is you can embed them in your assembly and reference them as web resources from your code.

To register a resource as WebResource you would use this line of code, you can do that in AssemblyInfo file:

[assembly: System.Web.UI.WebResource("imagename.jpg", "image/jpeg")]

For more information about WebResource parameter, please return to MSDN, currenlty I can mention that the 1st on is the resource name, and the 2nd one is the content-type of the resource, in our case it is an image so the content type is image/jpeg. If your resouece file is javascript, then the content-type would be text/javascript

And you can reference your resource using ClientScriptManager class through Page.ClientScript Property as the following

string resUrl = this.Page.ClientScript.GetWebResourceUrl(typeof(YouControlType), "imagename.jpg");

Now use your resUrl to display your image!.... BUT WAIT, this is not going to work!!

If you followed the MSDN code while you are VS.NET this is not going to work at all, your image or your resource file never appear.
Here are the Rule:

  1. You should know your Assembly default namespace.
  2. Recognize where exactly your resource file located in your project, "Its Path"
  3. Define the correct resource name.

Suppose your default namespace is Moses.WebControls, while your resource file name is ComboBox.js, this file is located on a folder named Resources/Scripts in your project -Dont care about your project name or assembly name, just focus on your Default namespace name-.

Now your resource file should be name "Moses.WebControls.Resources.Scripts.ComboBox.js".

The rule simpley is [Default namespace].[Resource Path from the project root -replace '/' with '.' of course-].[Resource FileName]

So you'll register your WebResource as the following:

[assembly: System.Web.UI.WebResource("Moses.WebControls.Resources.Scripts.ComboBox.js", "text/javascript")]

And you can get your resource URL as the following:

string resUrl = this.Page.ClientScript.GetWebResourceUrl(typeof(YouControlType), "Moses.WebControls.Resources.Scripts.ComboBox.js");

Hope this would help somebody

kick it on DotNetKicks.com

Posted: Feb 17 2008, 23:43 by mosessaur | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: ASP.NET | Tips | Visual Studio
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

Tip: Generating Local Resource Files

As I was working on multingual User Interface project; it was needed to generate resource files for all aspx & ascx files.
I knew that VS.NET 2005 has a local resource file generator. But it was weird when I select my ASPX page or user control and go to Tool menu and find that there are no Generate Local Resources command on the menu!

It didn't take so much time, I found the solution on ASP.NET Forums. It was simple: "he menu 'Tools > Generate Local Resources' is available when you display an aspx page or ascx". Also you must switch to design veiw before you Generate your local resources.

kick it on DotNetKicks.com

Posted: Feb 17 2008, 23:35 by mosessaur | Comments (1) RSS comment feed |
  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: ASP.NET | Tips | Visual Studio
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

ASP.NET 2.0 AJAX Timer Hacks! How to Pause ASP.NET AJAX Timer

UPDATE:
Matt Berseth posted a detailed information about this tip on his post Bug Bash: Enabling/Disabling the ASP.NET AJAX Timer using the Control's Client Side API. Much clearer and explained in details. [May 08, 2008]
----------------------------------------------------------------------------------------------------------------------------------

from about 2 weeks I wrote an article about how you can use ASP.NET 2.0 AJAX Timer control in a real world scenario side by side with RssToolKit.

The idea it to display RSS feed from deferent location in cycle using ASP.NET AJAX Timer. I also had an idea of pausing the Timer when the user move his mouse over the update-able area "Group Box that display feeds inside it". Of course this should be down from client side.

I searched the documentation for Client Side APIs related to the AJAX Timer control but I didn't find any. I had to hack inside AJAX Timer client library downloaded with ASP.NET AJAX Extensions, and I found what I want.

First I though that by setting client side enabled property using set_enabled(false) of the AJAX Timer I could get what I want; actually I was wrong, this will not pause the Timer.

Dig deeper, but not for too long, I found 2 methods _startTimer() and _stopTimer(), those were excatly what I was looking for.

bellow is a sample client code of how you can use these 2 methods:

   1: function startTimer() { var timer = $find("<%=ajaxTimer.ClientID%>"); timer._startTimer(); }
   2: function stopTimer() { var timer = $find("<%=ajaxTimer.ClientID%>"); timer._stopTimer(); } 

The above code assuming that you have an AJAX Timer control on the page named ajaxTimer. Call these method from your client side code, or add them as event handlers on your target elements.

I don't know why these are not documented, or we are not supposed to use them?! Actually I don't know. I thought that after using these methods the browser will cause a problem regarding client scripts, but both Opera and IE worked just fine without any problem. Also I didn't notice any slow down or hanging in both browsers.

Hope you find it useful.

kick it on DotNetKicks.com

Posted: Feb 17 2008, 18:48 by mosessaur | Comments (0) RSS comment feed |
  • Currently 4.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: ASP.NET AJAX | Client Side | Tips
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

SQL Server, Clean your Database Records and reset Identity Columns, The Shortest Path

Well, I had a small issue regarding writing a script to clean a database we have and reset its identity columns in all tables. Although the database wasn't huge one (less than 100 tables) I had to trace relations to be able to delete child table's records before parent's ones because of the foreign key constraints. The solution is disable the foreign keys and delete records with no fear of any errors then enables the constraints again.
Well, I found a solution to disable all constraints without the need to go on each table and disable it manually. and I was happy to know that I can use this solution in deleting all records from all tables. Not only this I was able to use the same solution to reset identity columns in all tables.
The solution was to use this built in stored procedure sp_MSforeachtable. For help about this proc search for it in Books online or use this sp_helptext sp_MSForeachtable.
Now back to my 6 lines, bellow is how I re-zeroed my Database:

   1: /*Disable Constraints & Triggers*/
   2: exec sp_MSforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
   3: exec sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL'
   4:  
   5: /*Perform delete operation on all table for cleanup*/
   6: exec sp_MSforeachtable 'DELETE ?'
   7:  
   8: /*Enable Constraints & Triggers again*/
   9: exec sp_MSforeachtable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
  10: exec sp_MSforeachtable 'ALTER TABLE ? ENABLE TRIGGER ALL'
  11:  
  12: /*Reset Identity on tables with identity column*/
  13: exec sp_MSforeachtable 'IF OBJECTPROPERTY(OBJECT_ID(''?''), ''TableHasIdentity'') = 1 BEGIN DBCC CHECKIDENT (''?'',RESEED,0) END'
kick it on DotNetKicks.com
Posted: Dec 09 2007, 09:13 by mosessaur | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: SQL Server | Tips
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

Sharepoint 2007 Installation with best pratice

Cris David founder of www.moss07.org blogged about how to Installation SharePoint 2007 with best practice. He prepared a very organized document about how to install and configure SharePoint 2007. The document is supposed to be in 2 parts. He published his first part while a go. I highly recommend reading this document if you are new to SharePoint or want to put your hand on the best pratice and smooth way to deploy SharePoint 2007.
I supposed to post this on my SharePoint blog but it seems to be down.
Posted: Jun 10 2007, 12:08 by mosessaur | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: SharePoint | Tips
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us