Wednesday, January 27, 2010

For using excel file as database

6:11 AM Posted by Unknown , No comments
For reading Excel files and getting the data
string FilePath = Server.MapPath("exmaple.xls");

DataSet myDataset = new DataSet();
string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FilePath + @";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
DataTable DTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
//here the code will read sheet from spreadsheet with any name --generic
OleDbDataAdapter myData = new OleDbDataAdapter
(@"SELECT * FROM [" +
DTable.Rows[0]["TABLE_NAME"].ToString() + "]", conn);
//
myData.Fill(myDataset);

Tuesday, January 26, 2010

Firebug Extensions

9:45 PM Posted by Unknown , No comments
Firebug is the most usefult addon tool for web development. It can help us to find the issues in css, ajax requests etc and many features. There are some other addons which can help to improve the utility of firebug.
Learn More

Monday, January 25, 2010

Saturday, January 23, 2010

Ajax and UpdatePanel performance improvement

7:38 PM Posted by Unknown , , , , No comments
Most of the newbie programmers like me are ajaxifying a site by putting updatepanels all over the site. Now, I came to know that, putting updatepanel will not help you to improve your site's speed. We are using it, since it is very easy. You can understand why ajax updatenpanels should be avoided from the following link

Why UpdatePanel Dangerous



If you still want to use updatepanel, check the following link to speed up the updatepanel performance.

Speeding up UpdatePanel



Also, you can use a dll, scriptreferenceprofiler, to find the ajax scripts used in a page and combine them, so that, only that script requests will be used in that specific page, which reduces the loading time. You can understand how to use it from the following msdn video.

Script Combining

You can download ScriptReferenceProfile from the following url
Download

Use them as follows

Add reference to the dll.
<%@ Register Assembly="ScriptReferenceProfiler" Namespace="ScriptReferenceProfiler" TagPrefix="cc1" %>

Top Money giving Paid To Click site

9:49 AM Posted by Unknown No comments
Its an off topic. I just came to know about this site. They are giving the maximum for click. 50 cents for just clicking banners and 1 USD for reading their emails. Also, referral bonus is there.

payingptr.com

Friday, January 22, 2010

Know the control which caused the postback

8:28 PM Posted by Unknown , No comments
I got this from some site. It can be used to know the control which caused the postback.

 public static Control GetPostBackControl(Page thePage)
    {
        Control myControl = null;
        string ctrlName = thePage.Request.Params.Get("__EVENTTARGET");
        if (((ctrlName != null) & (ctrlName != string.Empty)))
        {
            myControl = thePage.FindControl(ctrlName);
        }
        else
        {
            foreach (string Item in thePage.Request.Form)
            {
                Control c = thePage.FindControl(Item);
                if (((c) is System.Web.UI.WebControls.Button))
                {
                    myControl = c;
                }
            }

        }
        return myControl;
    }

Display updateprogress in the clicked position

8:22 PM Posted by Unknown , No comments
On the following example, progress bar(UpdateProgress1) is displayed on the position of the button which got clicked


function pageLoad()

     {     

           var manager = Sys.WebForms.PageRequestManager.getInstance();
   
          
       manager.add_beginRequest(OnBeginRequest);
   
    }

    function OnBeginRequest(sender, args)
    {
 
          var postBackElement = args.get_postBackElement();
          var position = $("#"+postBackElement.id).offset();
         
         
          $("#<%=UpdateProgress1.ClientID%>").css({'position' : 'absolute', 'z-index' : '1002', 'overflow' : 'auto','top' : position.top,'left' : position.left}).fadeIn(100);

}

JQuery default functions

8:21 PM Posted by Unknown No comments
Following is the jquery default function that is run. we can use this to get the ajaxrequests
function pageLoad() {
            if (!Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()) {
                Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(AjaxBegin);      
                Sys.WebForms.PageRequestManager.getInstance().add_endRequest(AjaxEnd);      

            }
        }

8:16 PM Posted by Unknown No comments
Use ScriptManager.RegisterStartupScript, when using ajax updatepanel to add javascript from codebehind.
for eg. just showing a message box, on of a button in updatepanel
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "scriptname", "var position=$('#" + Btn.ClientID + "').offset();$('#').html('Button clicked').css(position).fadeIn(2000).fadeOut(2000);", true);

can get position using position method of jquery

First Post

8:14 PM Posted by Unknown No comments
My First Post. Hope this blog will help me and others too.

I am going to post all the new things I am learning everyday regarding programming. Hope it helps somebody.