简体   繁体   中英

ASP.Net chat application javascript pop-up window

I am designing an ASP.Net chat 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM