Mohd Malaka Weblog

About anything….

  • Archives

  • Flickr Photos

    St Patrick Day 2009 Parade

    Garda

    Daffodil Day

    Wait For Me

    Twins

    More Photos
  •  

    July 2009
    M T W T F S S
    « May    
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
  • free counters

C#: Bind a DropDownList to IDictionary using AjaxPro

Posted by malakablog on May 1, 2009

- Implement an AjaxMethod to return IDictionary object

 

[AjaxPro.AjaxMethod]

public IDictionary AjaxGetIDictionary()

{

//Prepare the IDictionary object

}

- Use JavaScript to request the AjaxMethod AjaxGetIDictionary

MyAjaxClass. AjaxGetIDictionary (jsAjaxGetIDictionary_Callback);

- In the JavaScript function jsAjaxGetIDictionary_Callback add the IDictionary items to the DopDownList

function jsAjaxGetIDictionary (response)

{

     try

    {

         var DictionaryItems= response.value;

         if (DictionaryItems == null || typeof(DictionaryItems) != “object”)

        {

               return;

         }

         var myDropDownList = document.getElementById(“myDropDownList”);

         myDropDownList.options.length = 0;

         for (var i = 0; i < response.value.length; ++i)

         {

             myDropDownList.options[myDropDownList.options.length] = new Option(response.value[i].Value,response.value[i].Key);

           }

    }

    catch(e)

   {

   }

}

Posted in Uncategorized | Tagged: , , , , , , , , , | Leave a Comment »

C#:Using Dictionary as DropDownList Data Source

Posted by malakablog on March 31, 2009

I have IDictionary Object called ListOptions. To use it as the data source for an ASP.NET DropDownList called objDropDownList:

 

objDropDownList.DataSource = ListOptions;

objDropDownList.DataTextField = “Value”;

          objDropDownList.DataValueField  = “Key”;

          objDropDownList.DataBind(); 

 

 

 

Posted in Uncategorized | Tagged: , , , , , , , , , , , , , , | Leave a Comment »

T-Shirts for Software people

Posted by malakablog on March 6, 2009

1

3

4

5

6

7

8

Posted in Uncategorized | Tagged: , , , , , , , , , , , , , | Leave a Comment »

How to sort a collection to be used in DropDown List

Posted by malakablog on February 18, 2009

I have a collection object (EmployeesCollection) for custom Employee class, In the Employee class there are two properties Name and EmployeeID. I want to sort the EmployeesCollection by Name and use it in a DropDown List (ddEmployees).

 

DataTable dtEmployees = new DataTable();

          dtEmployees.Columns.Add(“Name”);

          dtEmployees.Columns.Add(“EmployeeID”);

          foreach (Employee vEmployee in EmployeesCollection)

          {

                    dtEmployees.Rows.Add(new object[] { vEmployee.Name, vEmployee. EmployeeID  });

          }

          dtEmployees.DefaultView.Sort = “Name”;

          ddEmployees.DataSource = dtEmployees;

          ddEmployees.DataTextField = “Name”;

          ddEmployees.DataValueField = “EmployeeID”;

          ddEmployees.DataBind();

 

 

 

 

Posted in Uncategorized | Tagged: , , , , , , , , , , , , | Leave a Comment »

Vignetting – Photoshop Tutorial

Posted by malakablog on January 21, 2009

This tutorial to show how to use the Photoshot to create Vignetting effect on photos

 

I will be using Photoshop version 8.0:

 

1- Open your image with Photoshop.

 

 

Open Photo

 

2- Create a new layer by selecting New/Layer from Layer menu (SHIFT+CTRL+N).

 

 

New Layer

 

3- Make sure to have the following color setting in the Tools

 

Colors

 

4- Fill the new layer with black (ALT+DELETE)

 

 

Black

 

5- Use the Rectangular Marquee Tool (M) to draw a rectangular as the following

 

 

Rectangular

 

6- Select the Feather (ALT+CTRL+D) from the Select menu and enter a value between 100-200 pixels.

 

 

Feather

 

7- Hit Delete to delete the selected area

 

 

Delete

 

8- From the Layers palette reduce the Opacity slider value to the required level

 

Opacity

 

And this is the final result

 

Final

Posted in Uncategorized | Tagged: , , , , , , , | Leave a Comment »

New Camera

Posted by malakablog on December 31, 2008

I got a new camera it is Canon EOS 450D

Canon 450D  

Check this for more information about it

  3 Ducks Reflection Colors Flower Cross Processing  Effect mmalaka. Get yours at bighugelabs.com/flickr

Posted in Uncategorized | Tagged: , , , , , , , , | Leave a Comment »

Firefox 2.0 – InnerHTML issue

Posted by malakablog on December 4, 2008

Sorry about the long time between posts. Hope to start posting again soon

 

Anyhow,

 

I was working on a web application that is updating the details of a <map> HTML element using the innerHTML, the new innerHTML value is being processed in the server side using AJAX function

 

I was using the following JavaScript function to do that

 

function jvUpdateImageMap(ImageMapHTML) 

{

    try

    {

          document.getElementById(“MyImageMap”).innerHTML= ImageMapHTML;

           

     }

catch(err)

          {

          }

          finally

          {

          }

}

 

That was working fine for all the browser including Firefox 3.0 but not for Firefox 2.0

 

After debugging this I found that for FireFox 3.0 the result of updating the InnerHTML is this

 

  <map id=”MyImageMap” >

          <area SHAPE=”rect” id=”0_30″ usemap=”MyImageMap” Border=”0″ href=”#” COORDS=”538,420,550,408″ />

 </map>

 

 

This is the correct expected result

 

But for FIreFox 2.0 the result was this

 

<map id=”MyImageMap” >

<map id=”MyImageMap” >

          <area SHAPE=”rect” id=”0_30″ usemap=”MyImageMap” Border=”0″ href=”#” COORDS=”538,420,550,408″ />

</map>

</map>

 

 

So to fix this I had to add those lines to the server side function that generate the new <map> HTML code  

If Context.Request.Browser.Browser = “Firefox” Then

       If Context.Request.Browser.MajorVersion = “2″ Then

               ImageMapHTML = ImageMapHTML.Replace(“<map id=”"MyImageMap”" >”, “”)

                ImageMapHTML = ImageMapHTML.Replace(“</map>”, “”)

        End If

End If

 

Posted in Uncategorized | Tagged: , , , , , , , , , , , , , , , , , , | Leave a Comment »

Geogrpahy of Women

Posted by malakablog on October 24, 2008

Between the ages of 15 – 20 a woman is like Africa.
She is half discovered, half wild.

 

 

 

Between the ages of 20 – 30 a woman is like America.
Fully discovered and scientifically perfect.

 

 

  

Between the ages of 30 – 35, she is like India & Japan.
Very hot, wise and beautiful!!!!!!!!!

 

 

  

Between the ages of 35 – 40 a woman is like France.
She is half destroyed after the war but still desirable.

 

 

  

Between the ages of 40 – 50 she is like Germany.
She lost the war but not the hope.

 

 

  

Between the ages of 50 – 60 she is like Russia.
Very wide, very quiet but nobody goes there.

 

 

  

Between the ages of 60 – 70 a woman is like England.
With a glorious past but no future.

 

 

 

After 70, they become Siberia.
Everyone knows where it is, but no one wants to go there.

 

Posted in Uncategorized | Tagged: , , , , , , , , , , , , , , , , | Leave a Comment »

Getting the Table Name of a field in a View (SQL2000, C#)

Posted by malakablog on October 10, 2008

So I have a View that join different tables, I wanted to get the Table name of a Field in the View. So I created a Function [GetTableName] with the following Inputs

 

-         View Name

-         Connection String of the View.

-         The required Field Name

 

This is the function

 

public string GetTableName (string ViewName, string ConnString, string FieldName)

        {

            SqlConnection MyConnection;

            string toReturn = ViewName;

 

            MyConnection = new SqlConnection(ConnString);

            MyConnection.Open();

 

            DataTable MyTable = MyConnection.GetSchema(“Views”);

            foreach (DataRow dRow in MyTable.Rows)

            {

                object[] sqlArray = dRow.ItemArray;

                if (sqlArray.GetValue(2).ToString() == ViewName)

                {

                    DataTable MyVTable = MyConnection.GetSchema(“ViewColumns”);

                    foreach (DataRow dVRow in MyVTable.Rows)

                    {

                        object[] sqlVArray = dVRow.ItemArray;

                        if (sqlVArray.GetValue(2).ToString() == ViewName)

                        {

                            if (sqlVArray.GetValue(6).ToString() == FieldName)

                            {

                                toReturn = sqlVArray[5].ToString();

                            }

                        }

 

 

                    }

 

                }

            }

           

            return toReturn;

        }

 

 

 

Posted in Uncategorized | Tagged: , , , , , , , , , , , , , , | Leave a Comment »

Using PageMethods/WebMethods to update Sessions variable

Posted by malakablog on October 8, 2008

I created functions for updateing/reading sessions variables using PageMthods and WebMethods, I am using VS2005 (VB.NET):

 

Import the web.services library

  Imports System.Web.Services 

 

This is the VB.NET function for setting the session variables

           <WebMethod()> _

Public Shared Function AjaxSetSession(ByVal SessionValue As String)

                    Try

                             HttpContext.Current.Session(“SessionKey”) = SessionValue

                   Catch ex As Exception

 

                   End Try

          End Function

 To access the session we need to use HttpContext.Current.Session

 

This is the VB.NET function for getting the session variables

       <WebMethod()> _

          Public Shared Function AjaxGetSession() As String

                    Try

                             AjaxGetSession = HttpContext.Current.Session(“SessionKey”)

                    Catch ex As Exception

                             AjaxGetSession = “Error”

                    End Try

    End Function

 

This is the JavaScript Code to set the session variable

 

PageMethods.AjaxSetSession(”PageMethods”,”WebMethods”)

This the JavaScript Code to read the Session Variables

 

PageMethods.AjaxGetSession(JSGetSessionSucess,JSGetSessionFaild);

 

JSGetSessionSucess is a JavaScript function that would be executed if the AjaxGetSession succeeded

 

       function JSGetSessionSucess(value, methodName)

      {

               try

              {

                        alert(value);

                }

catch(err)

               {

               }

               finally

               {

              }

      }

 

JSGetSessionFaild is a JavaScript function that would be executed if the AjaxGetSession failed

        function JSGetSessionFaild (ex, methodName)

      {

               try

              {

                        alert(ex.get_exceptionType());

                }

catch(err)

               {

               }

               finally

               {

              }

      }

 

Posted in Uncategorized | Tagged: , , , , , , , , , , , , , , | Leave a Comment »