Monday, September 29, 2008

Run a Server Side Code and Open a Popup Window onClick of a Link in Asp.net


There are 3 ways we can achieve this :

1) Create a LinkButton and add both client side as well as server side onclick event handlers :

<LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click>LinkButton <asp:LinkButton>

protected override void OnLoad(EventArgs e)
{
LinkButton1.Attributes.Add("onclick", "window.open('test.aspx');");
}

protected void LinkButton1_Click(object sender, EventArgs e)
{
//Server side code here
}

(Problem : Both the events occur simultaneously so if we have a scenario wherein we want the popup to open after the server side code is executed, this isn’t useful)

2) Render the script using Response.Write :

protected void LinkButton1_Click(object sender, EventArgs e)
{
//Server side code here

Response.Write("&lt;script&gt;");

Response.Write("window.open('test.aspx','_blank')");

Response.Write("&lt;/script&gt;");
}

(Problem : In some browsers the CSS of the background window gets affected with this solution)


3) Use the Page.ClientScript.RegisterClientScriptBlock method :

protected void LinkButton1_Click(object sender, EventArgs e)
{
//Server side code

string _url = "test.aspx";

this.Page.ClientScript.RegisterClientScriptBlock(
this.GetType(),
"openNewWindow", "window.open(\"" + _url + "\");",
true);
}

The 3rd one is the most efficient way in my view.

Wednesday, September 03, 2008

Whoa! Google Chrome has crashed. Restart Now ?

Google Crome

This was the first message I got after installing google’s new browser Google Chrome . . . :-)

But since then its working like a charm. . . . . Here are some of the features I like the most :

Thumnail view of the ‘Most Visited’ sites when you first open the browser

Google Crome Most Visited

Opening ‘incognito window’ for private browing (seems similar to IE-8 privacy feature )

Google Crome incognito window

‘Inspect Element’ to see the HTML source code of that element along with the DOM

Inspect Element

Inspector Window

John and Rory have also posted some performance and memory usage benchmarks compared to IE7 here and here.

Monday, September 01, 2008

A Paragraph that explains LIFE . . . .


Recently I got this email from one of my friend which really inspired me and gave a different vision of looking at life . . . . .



Arthur Ashe, the legendary Wimbledon player was dying of AIDS which he got due to infected blood he received during a heart surgery in 1983.

From world over, he received letters from his fans, one of which conveyed: "Why does GOD have to select you for such a bad disease"?

To this Arthur Ashe replied:

"The world over -- 50 million children start playing tennis, 5 million learn to play tennis,
500,000 learn professional tennis, 50,000 come to the circuit, 5000 reach the grand slam,
50 reach Wimbledon, 4 to semi final, 2 to the finals,
when I was holding a cup I never asked GOD 'Why me?'.
And today in pain I should not be asking GOD 'Why me?' "



Happiness keeps you Sweet,

Trials keep you Strong,

Sorrow keeps you Human,

Failure keeps you humble and Success keeps you glowing, but only

Faith & Attitude Keeps you going....

AddIn