I am designing an ASP.Net cha开发者_开发技巧t application. I have an online user list which are LinkButtons in a ListView. I want to click one of them and open a pop-up window. How can I do that?
Set your LinkButtons so they have an onclick attribute that opens a popup window.
Codebehind:
Dim username as String = "foo"
lnkbtn.Attributes.Add("onClick", "javascript:openWindow(" & username & ");return false;")
'The "return false" part is important - it stops the LinkButton from doing a postback.
Client-side:
function openWindow(username) {
window.open(my_url + username); //Where my_url is the URL that you want to open.
}
username
is just there as an example of how you can pass values through to Javascript.
精彩评论