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!
9eca0a68-d54a-4f08-9d4a-8ce3f47185ea|0|.0
Tags: javascript, c#