Install VMWare WorkStation 8 and VMWare Player on Fedora 16

November 9, 2011 at 3:48 PMQuang Ngoc

Because Fedora 16 came with new kernel 3.1.x. So you must patch your kernel to enable run VMWare WorkStation and VMWare Player (version 8).

This link is useful after you install.

http://weltall.heliohost.org/wordpress/2011/09/29/vmware-workstationplayer-fix-for-linux-3-1/

Just download file http://weltall.heliohost.org/wordpress/wp-content/uploads/2011/09/vmware8linux31fix.tar.gz , extract and run as root user

[root@duong Downloads]# ./patch-modules_3.1.0.sh

Posted in: Linux

Tags: ,

Using Ajax Animation to show a popup

September 14, 2011 at 6:08 AMQuang Ngoc

Here is sample code (stylesheet and aspx file):

.flyOutDiv
        {
            display: none;
            position: absolute;
            width: 450px;
            z-index: 2;
            opacity: 0;
            filter: (progid:DXImageTransform.Microsoft.Alpha(opacity=0));
            font-size: 11px;
            border: solid 1px #CCCCCC;
            background-color: #FFFFFF;
            padding: 3px;
        }
        .flyOutDivCloseX
        {
            background-color: #666666;
            color: #FFFFFF;
            text-align: center;
            font-weight: bold;
            text-decoration: none;
            border: outset thin #FFFFFF;
            padding: 3px;
        }

And in aspx file:

<asp:ImageButton ID="imgBtn2" ImageUrl="~/App_Themes/Button-Help-icon.png"
    Height="12px" Width="12px" ToolTip="Plus des informations" runat="server" OnClientClick="return false;"/>
<asp:Panel ID="pnl2" CssClass="flyOutDiv" runat="server">
    <div style="float: right;">
        <asp:LinkButton ID="btnClose2" runat="server" Text="X" OnClientClick="return false;"
            CssClass="flyOutDivCloseX" />
    </div>
    <div style="text-align: left;">
        <asp:BulletedList ID="BulletedList4" runat="server">
            <asp:ListItem>EC : En cours d'acquisition.</asp:ListItem>
            <asp:ListItem>AA : A acquérir.</asp:ListItem>
            <asp:ListItem>A-V : Acquis en théorie seulement, ou acquis et valorisé mais sans certitude d''être capable de reproduire.</asp:ListItem>
            <asp:ListItem>A+V : Acquis et valorisé plusieurs fois avec la certitude d'être capable de reproduire.</asp:ListItem>
        </asp:BulletedList>
    </div>
</asp:Panel>
<ajaxtoolkit:AnimationExtender ID="AnimationExtender3" runat="server" TargetControlID="imgBtn2">
    <Animations>
        <OnClick>
            <Sequence>
                <EnableAction Enabled="false"></EnableAction>

                <StyleAction AnimationTarget="pnl2" Attribute="display" Value="block"/>
                <Parallel AnimationTarget="pnl2" Duration=".3" Fps="30">
                    <Move Horizontal="-450" Vertical="-125"></Move>
                    <FadeIn Duration=".2"/>
                </Parallel>
                <Parallel AnimationTarget="pnl2" Duration=".5">
                     <Color PropertyKey="color" StartValue="#666666" EndValue="#666666" />
                    <Color PropertyKey="borderColor" StartValue="#666666" EndValue="#FF0000" />
                </Parallel>
            </Sequence>
        </OnClick>
    </Animations>
</ajaxtoolkit:AnimationExtender>
<ajaxtoolkit:AnimationExtender ID="AnimationExtender4" runat="server" TargetControlID="btnClose2">
    <Animations>
        <OnClick>
            <Sequence AnimationTarget="pnl2">
                <Parallel AnimationTarget="pnl2" Duration=".5" Fps="20">
                    <Move Horizontal="450" Vertical="125"></Move>
                    <Scale ScaleFactor="0.05" FontUnit="px" />
                    <Color PropertyKey="color" StartValue="#666666" EndValue="#666666" />
                    <Color PropertyKey="borderColor" StartValue="#FF0000" EndValue="#666666" />
                    <FadeOut />
                </Parallel>
                <StyleAction Attribute="display" Value="none"/>
                <StyleAction Attribute="height" Value=""/>
                <StyleAction Attribute="width" Value="450px"/>
                <StyleAction Attribute="fontSize" Value="11px"/>
                <EnableAction AnimationTarget="imgBtn2" Enabled="true" />
            </Sequence>
        </OnClick>
    </Animations>
</ajaxtoolkit:AnimationExtender>

Happy Coding!!!

Posted in: ASP.NET

Tags: , , ,

Paging and Sorting GridView which use DataTable as DataSource

September 14, 2011 at 6:03 AMQuang Ngoc

Here is sample code to enable paging and sorting gridview which use DataTable as DataSource:

protected void gridCompetence_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gridCompetence.PageIndex = e.NewPageIndex;
        BindListSkill();
    }
    protected void gridCompetence_Sorting(object sender, GridViewSortEventArgs e)
    {
        System.Data.DataTable dataTable = gridCompetence.DataSource as System.Data.DataTable;

        if (dataTable != null)
        {

            dataTable.DefaultView.Sort = e.SortExpression + " " + GetSortDirection(e.SortExpression);
            BindListSkill();
        }
    }
    private string GetSortDirection(string column)
    {
        string sortDirection = "ASC";

        string sortExpression = ViewState["SortExpression"] as string;

        if (sortExpression != null)
        {
            if (sortExpression == column)
            {
                string lastDirection = ViewState["SortDirection"] as string;
                if ((lastDirection != null) && (lastDirection == "ASC"))
                {
                    sortDirection = "DESC";
                }
            }
        }

        ViewState["SortDirection"] = sortDirection;
        ViewState["SortExpression"] = column;

        return sortDirection;
    }

The methode BindListSkill(); can be replaced by

gridCompetence.DataSource = dt; // your DataTable here
gridCompetence.DataBind();

Happy Coding!!!

Posted in: ASP.NET

Tags: , , ,

Changing color when hover mouse over a row in gridview

September 14, 2011 at 5:59 AMQuang Ngoc

This function for changing color when hover mouse over a row in gridview:

protected void gridCompetence_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.RowState == DataControlRowState.Alternate)
            {
                e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#A3C952';");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#f7fff8';");
            }
            else
            {
                e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#A3C952';");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#eefef0';");
            }
        }
    }

Happy Coding!!!

Posted in: ASP.NET

Tags: ,

Show tooltip for each item in GridView, DropDownList

September 14, 2011 at 5:55 AMQuang Ngoc

To show tooltip for each item in a GridView, you can do like that:

protected void gridCompetence_RowDataBound(object sender, GridViewRowEventArgs e)
{

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        System.Web.UI.WebControls.Label lblDomaineGrid = (System.Web.UI.WebControls.Label)e.Row.FindControl("lblDomaineGrid");
        if (lblDomaineGrid !=  null)
            lblDomaineGrid.ToolTip = gridCompetence.DataKeys[e.Row.RowIndex]["DOMAINE_DEF"].ToString();
     }
}

In DropDownList, we can using:

for(int i=0; i<=lstDomaine2.Items.Count-1; i++)
                {
                    lstDomaine2.Items[i].Attributes.Add("Title", lstDomaine2.Items[i].Text + ":\n" + Competences.FetchDomaineComment(lstDomaine2.Items[i].Text));
                }

That must in in RowDataBound event of GridView.

Happy Coding!!!

Posted in: ASP.NET

Tags: ,

How to disable selecting some items in DropdownList

September 14, 2011 at 5:46 AMQuang Ngoc

Sometimes, we need to disable selecting some items in a DropDownList. Here is my simple code to do that.

ListItem item1 = lstNiveauMin.Items.FindByValue(i.ToString());
item1.Attributes.Add("style", "color:gray;");
item1.Attributes.Add("disabled", "true");

If your dropdownlist is in GridView - Edit Mode, you can find it by:

DropDownList lstNiveauRequis = ((GridViewRow)gridCompetence.Rows[gridCompetence.EditIndex]).FindControl("lstNiveauRequis1") as DropDownList;

May be it's helpful in your apps. 

Happy Coding!

Posted in: ASP.NET

Tags: ,

Install ATI driver on Linux Mint 11

September 13, 2011 at 5:30 PMQuang Ngoc

After one day, I had found how to install video driver in my Linux Mint 11 64 bit

My card is ATI HD 5470, so: first is download the driver at: 

http://www2.ati.com/drivers/linux/ati-driver-installer-11-8-x86.x86_64.run 

http://www2.ati.com/drivers/linux/ati-driver-installer-11-9-x86.x86_64.run

http://www2.ati.com/drivers/linux/ati-driver-installer-11-10-x86.x86_64.run (Update October 31, 2011)

After that:

$ sudo apt-get remove --purge fglrx fglrx_* fglrx-amdcccle* fglrx-dev* xorg-driver-fglrx
$ sudo apt-get remove --purge xserver-xorg-video-ati xserver-xorg-video-radeon
$ sudo apt-get install xserver-xorg-video-ati
$ sudo apt-get install --reinstall libgl1-mesa-glx libgl1-mesa-dri xserver-xorg-core
$ sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
$ sudo reboot

Reboot computer, and install the driver file I had downloaded:

$ sudo sh ./ati-driver-installer-11-8-x86.x86_64.run
$ sudo aticonfig --initial -f

Test the driver:

quangngoc@quangngoc-Aspire-4820TG ~ $ fglrxinfo
display: :0  screen: 0
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: ATI Mobility Radeon HD 5400 Series 
OpenGL version string: 4.1.11005 Compatibility Profile Context

quangngoc@quangngoc-Aspire-4820TG ~ $ fgl_glxgears
Using GLX_SGIX_pbuffer
1079 frames in 5.0 seconds = 215.800 FPS
1153 frames in 5.0 seconds = 230.600 FPS
949 frames in 5.0 seconds = 189.800 FPS
1072 frames in 5.0 seconds = 214.400 FPS
1008 frames in 5.0 seconds = 201.600 FPS

Now all working well. More link: http://wiki.cchtml.com/index.php/Debian

Posted in: Linux

Tags: , ,

How to manupulate with excel file in ASP.NET

September 13, 2011 at 3:52 AMQuang Ngoc

During my internship at SunTseu, I had found how to read, write in excel file.

Read:

FileStream stream = File.Open(AppDomain.CurrentDomain.BaseDirectory + "/ImportSkills/Import/FEST2011.xls", FileMode.Open, FileAccess.Read);
Excel1.IExcelDataReader excelReader = Excel1.ExcelReaderFactory.CreateBinaryReader(stream);
DataSet result = excelReader.AsDataSet();
System.Data.DataTable dt = result.Tables["COMPETENCES"];

"COMPETENCES" in the last line is spreadsheet of your excel file. Here, we have a DataTable and can do anything we want. For more information, read this link: http://exceldatareader.codeplex.com/. I use Excel Data Reader

Write:

Application myExcelApp;
Workbooks myExcelWorkbooks;
Workbook myExcelWorkbook;

object misValue = Missing.Value;
myExcelApp = new ApplicationClass();
myExcelApp.Visible = false;
myExcelWorkbooks = myExcelApp.Workbooks;
String fileName = AppDomain.CurrentDomain.BaseDirectory + "ImportSkills\\Import\\FEST2011.xls";
myExcelWorkbook = myExcelWorkbooks.Open(fileName, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue);

try
{
	Worksheet myExcelWorksheet = (Worksheet)myExcelWorkbook.Sheets.get_Item(1);

	String cellFormulaAsString = myExcelWorksheet.get_Range("G1", misValue).Formula.ToString();
	// this puts the formula in Cell A2 or text depending whats in it in the string.

	myExcelWorksheet.get_Range("G1", misValue).Formula = "2012";
	myExcelWorkbook.Close(true, misValue, misValue);
}
catch (Exception ex)
{
	Response.Write(ex.Message);
}

I use Microsoft Excel 12.0 Object Library. Here is more information: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/ef11a193-54f3-407b-9374-9f5770fd9fd7

Happy Coding! ...

Posted in: ASP.NET

Tags:

Linux Mint, Debian - How to enable non-free packages.

September 12, 2011 at 7:03 PMQuang Ngoc

Today, I had tried to install ATI driver on my Linux Mint 11. The problem had come while I enable non-free packages.Because Linux Mint is base on Ubuntu and Debian too, so we need to edit source list:

sudo gedit /etc/apt/sources.list

Simply add non-free to the respective URLs you wish to use:

deb http://http.us.debian.org/debian stable main contrib non-free

Running apt-get update will update your local repo with the package listing. But you might be have an error like this:

W: GPG error: http://http.us.debian.org stable Release:
The following signatures couldn't be verified because the public key is not available: 
NO_PUBKEY AED4B06F473041FA NO_PUBKEY 64481591B98321F9

This's because you have not GPG key in your machine. Try adding this by

quangngoc@quangngoc-Aspire-4820TG ~ $ gpg --keyserver subkeys.pgp.net --recv AED4B06F473041FA 
gpg: directory `/home/quangngoc/.gnupg' created 
gpg: new configuration file `/home/quangngoc/.gnupg/gpg.conf' created 
gpg: WARNING: options in `/home/quangngoc/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/quangngoc/.gnupg/secring.gpg' created 
gpg: keyring `/home/quangngoc/.gnupg/pubring.gpg' created 
gpg: requesting key 473041FA from hkp server subkeys.pgp.net 
gpg: /home/quangngoc/.gnupg/trustdb.gpg: trustdb created 
gpg: key 473041FA: public key "Debian Archive Automatic Signing Key (6.0/squeeze) <ftpmaster@debian.org>" imported 
gpg: no ultimately trusted keys found 
gpg: Total number processed: 1 
gpg: imported: 1 (RSA: 1)
quangngoc@quangngoc-Aspire-4820TG ~ $ gpg --export --armor AED4B06F473041FA KEY | sudo apt-key add -
[sudo] password for quangngoc:

With some key, I have problem with key server:

quangngoc@quangngoc-Aspire-4820TG ~ $ gpg --keyserver subkeys.pgp.net --recv 64481591B98321F9 
gpg: requesting key B98321F9 from hkp server subkeys.pgp.net ?: subkeys.pgp.net: Connection refused 
gpgkeys: HTTP fetch error 7: couldn't connect: Connection refused 
gpg: no valid OpenPGP data found. gpg: Total number processed: 0

Be best way is using it IP adress:

quangngoc@quangngoc-Aspire-4820TG ~ $ gpg --keyserver 195.113.19.83 --recv-keys 64481591B98321F9 
gpg: requesting key B98321F9 from hkp server 195.113.19.83 
gpg: key B98321F9: public key "Squeeze Stable Release Key <debian-release@lists.debian.org>" imported 
gpg: no ultimately trusted keys found gpg: Total number processed: 1 
gpg: imported: 1 (RSA: 1) 
quangngoc@quangngoc-Aspire-4820TG ~ $ gpg --export --armor 64481591B98321F9 KEY | sudo apt-key add 
- OK

To find host IP adress, you nedd using

quangngoc@quangngoc-Aspire-4820TG ~ $ host subkeys.pgp.net 
subkeys.pgp.net has address 195.113.19.83 
subkeys.pgp.net has address 208.90.26.99 
subkeys.pgp.net has address 213.239.206.174 
subkeys.pgp.net has address 64.71.173.107 
subkeys.pgp.net has address 116.240.198.71

Posted in: Linux

Tags: , ,

Cannot access GMail using Google Chrome

September 10, 2011 at 10:43 AMQuang Ngoc

There are some people told me that they cannot access to gmail using Google Chrome browser. Most of them using Windows XP.

This problem can be solved by:

  1. Clear cookies, user data,... Using CCleanner is the best choise
  2. Make sure the system date time is correct. If not, set to the current date time, and all will work well from now

Posted in: Google

Tags: ,