Wednesday, July 20, 2011

HighLight Grid View Selected Row Using Jquery..?

All we need to do is that on mouseover on gridview rows assign any CSS and on mouseout, remove that CSS. Rather than using mouseover and mouseout method seperately, jQuery provides another method named "hover()" which serves purpose of both the methods.


    <script type="text/javascript" language="javascript">
 
       $(document).ready(function() {
          $("#<%=gvCustomer.ID%> tr").hover(function() {
            $(this).css("background-color", "Lightgrey");
           }, function() {
           $(this).css("background-color", "#ffffff");
          });
        });
 
    </script>


My Grid view structure is.


<asp:GridView ID="gvCustomer" runat="server" AutoGenerateColumns="False"
            DataKeyNames="ID" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
                    ReadOnly="True" SortExpression="ID" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Age" HeaderText="Age" SortExpression="Age" />
            </Columns>
</asp:GridView>


Here the above code highlighted header row as well. Solution to overcome header row highlighted solution is here.


  <script type="text/javascript" language="javascript">
 
        $(document).ready(function() {
          $("#<%=gvCustomer.ID%> tr:has(td)").hover(function() {
            $(this).css("background-color", "Lightgrey");
           }, function() {
           $(this).css("background-color", "#ffffff");
          });
        });
 
    </script>


Enjoy Coding:)

Tuesday, July 12, 2011

Best way to implement support for multiple languages in a web app?

There are some basic trick to make multi language supported application:

1. Store data in UTF in your DB.  

2. Do not hard code strings anywhere in the code. Use resource files so you can translate just them to enable support for a new language.

3. Do not hard code any styles in the HTML(like: float:left, etc.) but externalize them in CSS files. That way, you don't need an army of developers to support Arabic, which is read from right to left.

4. Pay attention to common areas (such as header, footer, etc., which maybe left/right aligned) typically reserved for branding and navigation. Like the styles above, these are affected by I18N.
I18N is actually easy and requires only a little planning and care.

Njoy Coding......:)