create javascript pop up window link using c#

by aherrick 8. July 2008 07:50

Today I was working on some code and I needed to programatically create a link with the ability to have a javascript pop up.  The code is as follows:

string javascriptLink = "<a href=\"javascript: void(0)\" onclick =\"window.open('YourPageHere.aspx', '', 'scrollbars=0');return false;\">javascript link</a>";

To take this code a little further as in my case I needed to pass a query string to the page I wanted to load.

Edit your string like so:

string javascriptLink = "<a href=\"javascript: void(0)\" onclick =\"window.open('YourPageHere.aspx?Id=" + yourId + "', '', 'scrollbars=0');return false;\">javascript link</a>";

where yourId is the variable you want to pass.

Let me know if it worked for you. It's just that easy! 

Tags: ,

Comments

7/9/2008 6:38:16 AM #

Douglas Douglington

Oh dang! It is just that easy!

Douglas Douglington United States



Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen
Tweaked by ajondeck.NET

About the author

Andrew Herrick
I am a full time developer for Blue Horseshoe Solutions based out of Carmel, Indiana. I enjoy learning new technology and hope to give back with some of the cool things I pick up along the way.  Check me out on Stack Overflow!


Categories

None

Recent comments

Comment RSS

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in  anyway.

© Copyright 2008