Tuesday, August 31, 2010

Baansuri by kumar Vishwas

तुम अगर नहीं आई गीत गा न पाऊँगा
सांस साथ छोड़ेगी सुर सजा न पाऊँगा
तो तान भावना की है शब्द शब्द दर्पण है 
बांसुरी चली आओ होंठ का निमंत्रण है 

तुम बिना हथेली की हर लकीर प्यासी है
तीर पार कान्हा से दूर राधिका सी है
रात की उदासी में याद संग खेला है 
कुछ गलत न कर बैठे मन बहुत अकेला है 
औषधि चली आओ चोट का निमंत्रण है 

तुम अलग हुई मुझसे सांस की खताओं से 
भूख की दलीलों से  वक़्त की सजाओं से 
दूरिओं समझती है दर्द कैसे सहना है
आँख लाख चाहे पर होंठ से न कहना है 
कंचनी कसौटी को खोट का निमंत्रण है 
बासुरी चली आओ होठ का निमंत्रण है




Monday, August 30, 2010

 WARNING: 5 Reasons why you should NEVER fix a computer for free.

It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul.

We love the accolades. We love to be seen as the digital white knight fixed the server, the computer, the email, and anything else that life depends on.

We love it so much, we sometimes make horrible decisions. Sometimes, we work "FOR FREE."

We've all done it. A friend, a neighbor, a relative, a good client, a bad client, a pretty girl... Whoever it was, and for whatever reason, we all threw them a technological bone and fixed something for free. In rare instances, it can be a rewarding experience. Perhaps your buddy gave you a beer. Maybe someone said thank you. Maybe there was a smile on their face, and that was rewarding enough.

More likely, however, that five minute task you thought you were signing up for turned into 40 minutes, then an hour, then a commitment. Wow. You didn't see that coming.

There are 5 reasons you should ALWAYS hand out a bill.


You Break it You Bought it.
When you sit down to fix a problem that presented as a simple one you are creating a contract. Not a legal contract, but a social one. The computer owner is trusting their computer with you. It's their baby, and you're the doctor. So you sit down, and begin to fix a problem. In the process, something else breaks. You fixed one thing, but something else goes awry. What's the best part? Neither you nor the user notice it is broken until a day later when they call you to blame you for breaking something else. "I thought you were going to fix it." They complain. This is the primary reason you charge money to fix something. You break it, you bought it. The user / owner will expect you to warranty your service even though THEY received all the value of your time, and you received nothing in exchange.

People don't respect things that are free.
I learned that quote from a man who runs a non-profit organization. Image that. A man who solicits donations for a living candidly told me "people don't respect things that are free." You know what? He's right. Free advice. Free upgrade. Free entry. None are valued. Free advice is seldom wanted. Free upgrade was something you were going to get anyway. Free entry? The band playing tonight must not be any good. People associate the value of service with the amount of money that is exchanged for it. How else do you think that lawyer can get away with charging $400 an hour? People naturally make the assumption that if it costs an arm and a leg, then it must be worth it. So, if customers and friends will assume that the most expensive car is the best one, what will they assume of the free car? Do you want the heart surgeon who charges $500,000 per surgery or the one who works for beer to operate on your mother?

They will expect it forever.

In law, the concept of a precedent is vitally important. Judges and lawyers look to previous cases to decide what the interpretation of the law was because if a case was settled one way before, chances are, it will be settled that way again. Gamblers playing craps look at the past behavior of the dice to, mistakenly, assume that the good luck will continue. Users will figure if you fixed it once for free, you'll do it forever for free. There is no reason why they should respect the thousands of hours you have spent learning and researching the art of computer science. There is no reason that they should respect the certifications you hold. There is no reason that they should honor your abilities by paying your fees. Why? Because you did it for free. Once! When they come back and you try to get fees, they will meet you with resistance in the form of guilt. "I thought we were friends" they cry. "You didn't charge me anything last time." They argue. Setup the expectation that they are going to pay (or barter) from the onset. Demand the respect that you deserve. Make sure they understand you are a professional. After all, that is the difference between a professional and an amateur. Professionals get compensated for their skills.

4The demands will only grow with time.

Give them an inch, and they will take you through three operating system upgrades, two virus infections, and a crashed hard drive. Once you've set the precedent and created the expectation that you are their knight in shining armor, they will begin to call you for everything. They will suck up your time and resources. They will not be grateful. They will involve you in 30 minute hypothetical conversations then disagree with your expertise.

It Weakens Your Backbone
Working for free is not only unprofitable, it weakens your constitution as a professional consultant. For many consultants, asking for money is difficult. They email out a silent invoice after the fact and hope they get paid. This practice can lead to unbalanced books, debt, and a going out of business sign. The simple fact is: if you don't ask for your money, you're not going to get paid. No one just hands out checks. Setting up the expectation, especially when you fix a computer for the first time for a client, is vitally important in establishing boundaries that ensure you are paid in a timely fashion. Working for free, throwing out freebies, "comp"-ing your time hurts your ability to ask for the sale. It hurts your credibility because the client will assume that if you're not charging them for a given task, you didn't know what you were doing or you made mistakes. It may give you butterflies, but ask for the money. Do it openly and notoriously. Your clients will take it as a sign of confidence.

response.End v/s response.Flush

So, I was writing this class to export my Datatable into a xls spreadsheet. Pretty straightforward code with no fancy bells or whistles when suddenly .NET started throwing the following exception:


IP= , xxx.xxx.xxx.xxx
SOURCE - mscorlib
TARGET SITE - Void AbortInternal()
MESSAGE - Thread was being aborted.
BASE ERROR SOURCE = mscorlib
INNER EXCEPTION =
EXCEPTION DATA = System.Collections.ListDictionaryInternal+NodeKeyValueCollection
STACK TRACE = at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at ExportData.ExportDetails(DataTable DetailsTable, ExportFormat FormatType, String filename)
at xxx_Search_xxx.getcsv(Object o, EventArgs e)
TARGET SITE = Void AbortInternal()
############################################


I was pretty baffled for a while and kept debating if this was normal behavior and if it is possible to gracefully abort instead of (what looks like) a sudden abrupt abort

Yes, this is indeed by design. Microsoft has even documented it. 



There is no such thing as a "graceful" abort. You could simply Flush() the response, though, instead of ending it and let the framework take care of closing the connection for you. I'm assuming in this case that you want the response sent to the client, i.e., the typical case.
According to MSDN, calling Response.End() throws the ThreadAbortException when the response ends prematurely. You really should only call Response.End() when you want the exception raised. Else always Response.Flush();


Wednesday, August 25, 2010

inspecting all the session variables

I needed to inspect all of my existing Session Variables and finally found a sweet way...

  for (int i = 0; i < Session.Contents.Count; i++)
            {
                Response.Write(Session.Keys[i] + " - " + Session[i] + "
");
            }

But then I realized, this works fine in the Code behind file--which solves my problem.


However, I was initially trying to access the Session object from a Business Logic Layer, and I did not see Session object available at that level. For example, in my BLL whenever I type in Session, the intellisense no longer gives me Session.Add, Session.Contents, etc.

So, it got me wondering if there is a way that I can access Session from someplace other than .aspx? I looked at the various System includes and those didnt have any bearing on this issue.


I was hoping to have a BLL.Global.ClearSessionDataSetVars() that could be called from multiple places.

and then I found HttpContext.Current.Session



Now all is well...

Small things make me happy

    Today as I was coding, I was writing a regular "if-else" and decided to look at msdn for something different.


So, I found this cool way of writing simple "if-else"


  string[] coding = getVal.Text.Split(getVal.Text.Contains("-") ? '-' : ' ');





 Very elegant and very simple to understand. I love it !! 

Tuesday, August 24, 2010

Binding Data to Gridview with sorting

    private void bindInstitutionCourses()
    {
        string sqlQuery = "SELECT data from datatable";
        DataTable resultTable = getDataTable(sqlQuery, 4);
        DataView    dv = new DataView(resultTable);
        if (ViewState["sortExpr"] != null)
        {
            dv.Sort = (string)ViewState["sortExpr"] + " " + sortingOrder;
        }
        gvShowCoursesInstitution.DataSource = dv;
        gvShowCoursesInstitution.DataBind();
        dv.Dispose();
        resultTable.Dispose();
      
    }

  
    protected void gridView_Sorting(object sender, GridViewSortEventArgs e)
    {
        ViewState["sortExpr"] = e.SortExpression;
        bindInstitutionCourses();
    }



 private string sortingOrder
    {
        get
        {
            if (ViewState["sortingOrder"] != null)
            {
                if (ViewState["sortingOrder"].ToString() == "desc")
                {
                    ViewState["sortingOrder"] = "asc";
                }
                else
                {
                    ViewState["sortingOrder"] = "desc";
                }

            }
            else
            {
                ViewState["sortingOrder"] = "desc";
            }

            return ViewState["sortingOrder"].ToString();
        }
        set
        {
            ViewState["sortingOrder"] = value;
        }
    }

Current Page URL in C#


Get the current page URL


There are times in your scripts when you are going to want to get the current page URL that is shown the browser URL window.
 For example maybe a page URL has Querystring info appended to it and you need to send an email off to someone with that same exact URL and Querystring information. There are plenty of other reasons as well.

Here is some code to do it.


Lets say the current page is simply "http://www.mysite,com/view_user.asp"

This is all you need to get you the current page URL
< %
Thispage ="http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL")
% >


Now, if your page has Querystring info and variables you want as well.
Like so "http://www.mysite,com/view_user.asp?ID=1&Name=Fred"

you would use code like this.

< %
Thispage ="http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") & "?" & Request.Querystring
% >


If your page had Form info that might have been posted to it you would use code like this.

< %
Thispage = "http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") & "?" & Request.Form
% >


If your page had both Querystring and Form info you could try code like this.

< %
Thispage = "http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") & "?" & Request.Querystring & Request.Form
% >

Monday, August 23, 2010

C# tips

get lots of work done saving different copies of my page.

then i make a slight alteration and BOOM!!!!!!

i get this message:

Server Error in '/appName' Application. 

Compilation Error 


Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).

Source Error:

Line 1:
Line 2: Partial Class secure_Default
Line 3: Inherits System.Web.UI.Page
Line 4: 



for any one who wants to know.......

i sorted this out by changing the two bits of code:


===================================
in the page itself i changed:



to



===================================
and then in the code behind the page i changed the name of the partial class to match it:

Partial Class secure_homeInherits System.Web.UI.PageProtected Page_Load



Guys, whenever this happens, check your other pages. You most likely have a class duplicated somewhere else on your site. Happens all the time when retiring an old page but leaving it on the server. Make sure the class isn't declared in any other page that happens to be on the server - confuses the compiler since it doesn't know which one to use.

Pays to keep your site clean and tidy. I have spent many painful hours poring over these issues just to find out I didn't remove an obsolete page with the same class name in it.



May be a good idea that when you do that, add .Retired to the end of the namespace the old page lives in.

Wednesday, August 18, 2010

Kumar Vishwas

जिस की धुन पर दुनिया नाचे दिल ऐसा एकतारा है 
जो तुमको भी प्यारा है और हमको भी प्यारा है
झूम रही है सारी दुनिया जब के हमारे गीतों पर 
तब कहती हो प्यार हुआ है क्या अहसान तुम्हारा है 

Tuesday, August 17, 2010

Confirm Message Box before Deleting in Datagrid in ASP.Net is very useful in all applications.


Confirm Message Box before Deleting in Datagrid in ASP.Net is very useful in all applications.


Confirm Message Box before Deleting
Scenarion I
To use confirm Message box before delete operation uses JavaScript for confirmation box. You have to add JavaScript on button.
Page_Load
if(!IsPostBack)   btnConfirm.Attributes.Add("onclick","return confirm('Do you want to Delete');");
Once clicked Ok button on Confirm Box it executes Button_Click server event else doesn’t do anything.
btnConfirm_Click

//Your server code to delete
Scenario II
The DataList and DataGrid controls easily allow to add a "Delete" button/hyperlink in your template. When clicked, this button/link raises a DeleteCommand event that you can handle to delete the data item.



DataGrid’s Template Delete Button raises DeleteCommand event after clicking Delete Button of DataGrid. We needs to write javascript confirm method to this template button. This should be write in DataGrid’s ItemCreated event because it fires when datagrid’s item has been created.
private void dg_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{

//Check for Item and Alternate Items if(e.Item.ItemType==ListItemType.AlternatingItem || e.Item.ItemType==ListItemType.Item)
  {
 Button btn=(Button)e.Item.Cells[0].Controls[0];
btn.Attributes.Add("onclick","return confirm(‘Do you want to continue?’);");
  }
}

Friday, August 6, 2010

Kumaar barabanki

मुझको शिकस्त-ऐ-दिल का मज़ा याद आ गया
तुम क्यों उदास हो गए तुम्हे क्या याद आ गया

कहने को ज़िन्दगी थी बोहत मुख़्तसर मगर 
कुछ यु गुज़र हुई कि खुदा याद आ गया

बरसे बगैर जो घटा घिर के खुल गयी
एक बेवफा का अहदे ऐ वफ़ा याद आ गया

मांगेंगे अब दुआ के उसे भूल जाए हम 
लेकिन जो वो बा-वक़्त-ऐ-दुआ याद आ गया

हैरत तुमको देख के मज्जिद में ऐ कुमार 
क्या बात हो गयी जो खुदा याद आ गया



अब आंसू संभलते नहीं है संभाले
तुम्हारी अमानत तुम्हारे हवाले 



वही फिर मुझे याद आने लगे है
जिन्हें भूलने में ज़माने लगे है 

ना हारा है इश्क और न दुनिया थकी है
दिया जल रहा है हवा चल रही है

सुकून ही सुकून है ख़ुशी ही ख़ुशी है
तेरा गम सलामत मुझे क्या कमी है

वो मौजूद है और उनकी कमी है
मोहब्बत भी तन्हाई ये दायमी है

खटक गुदगुदी का मज़ा दे रही है
जिसे इश्क कहते है शायद यही है 

चरागों के बदले मकां जल रहे है
नया है ज़माना नयी रौशनी है 

मेरे राहबर मुझे गुमराह कर दे
सुना है के मंजिल करीब आ गयी है 


Thursday, August 5, 2010

anjum rahbar

और तो कुछ भी नहीं पास निशानी तेरी 
देखती रहती हूँ तस्वीर पुरानी तेरी

लडकियां और भी मंसूब तेरे नाम से है
क्या कोई मेरी तरह भी है दीवानी तेरी

मै अगर होठं भी सी लूं तो मेरी ख़ामोशी
सारी दुनिया को सुना देगी कहानी मेरी

मेरे फूलों मे महकता है पसीना तेरा
और हाथों मे खनकती है जवानी तेरी 

राजमहलों मे कनीजों का रहा है कब्ज़ा
और जंगल मे भटकती रही रानी तेरी 

देखती रहती हूँ तस्वीर पुरानी तेरी

Tuesday, August 3, 2010

In Mac OS X, how can I boot from a CD or DVD and/or ignore my startup disk?

Normally, to set an alternate startup volume, such as a bootable CD or DVD, you should use the Startup Disk system preference. However, if your regular boot disk is damaged or if you can't set the CD or DVD as a startup device from the system preference, try one of the following options:

  • Restart your computer and immediately press the Option key. Icons for all available startup volumes will appear. Click the one you want to boot from, and then click the right arrow button to complete the startup process.
  • Restart your computer and immediately press Command-Option-Shift-Delete. You must press all the keys at once. The computer will start to boot from the CD or DVD drive. If there isn't a bootable disc inside the drive when you begin the reboot, the computer will attempt to boot from another partition or drive.
  • Restart your computer and immediately press the  c  key. The computer will look for a bootable CD or DVD and, if it finds one, will use it as its startup device.