how to use href in Datalist control to use window.open(), without any post back

Hello,
i want to display some users in a DataList control in such a way that the users should be like a link and upon click there should be a window.open, there should be no post back.

how to do that, i mean how to assign values to the <a href="?"></a>

thanks
LVL 3
apnamianAsked:
Who is Participating?
 
VincentPugliaCommented:
Hi,

  I'm not an Asper, but you might try something like the following:


<ItemTemplate>
<a href="#" onclick="newwin = window.open('<%#Container.DataItem("userURL")%>','newwin','width=300,height=100');return false;"><%#Container.DataItem("userName")%></a>
</ItemTemplate>

The above presumes your xml page has 2 datasets: userURL & userName.   You may have to fiddle with the quotes and/or possibly add "&" between the html & the asp.

You also might want to consider using the repeater control rather than the dataset constrol, since the latter uutomatically encloses the items within a table and the former leaves you the option of using <ul>s.

Finally, here are two links from W3school:

datalist:  http://www.w3schools.com/aspnet/aspnet_datalist.asp
repeater:  http://www.w3schools.com/aspnet/aspnet_repeater.asp
0
 
thirdCommented:
use this,

<a href="#" onclick="newwin = window.open('username.html','newwin','width=300,height=100');return false;">username</a>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.