我需要在显示用户名列表的 ASP.NET 网页(aspx)内创建一个小窗口,当您单击用户名时,我需要一个新的浏览器窗口(不是选项卡)来打开特定大小. 我可以处理打开新的浏览器窗口,假设我使用的任何控件都可以让我进入我可以调用的代码隐藏函数......
string url = "http://www.dotnetcurry.com";
ScriptManager.RegisterStartupScript(this, this.GetType(), "OpenWin", "<script>openNewWin ('" + url + "')</script>", false);
这是链接页面中的标记。
<script language="javascript" type="text/javascript">
function openNewWin(url) {
var x = window.open(url, 'mynewwin', 'width=600,height=600,toolbar=1');
x.focus();
}
</script>
1.) 我应该使用什么控件来解决这个问题,从数据库中获取相应的用户名后结构是什么样的?
这是我最接近的......这段代码使用了一个 ASP.NET 项目符号列表,我试图将它绑定到一个 HTML 链接列表,我不想在任何地方指向它,而是让我进入代码隐藏。相反,此代码实际上在页面上呈现为 HTML(它没有被解析为超链接..)
protected void Page_Load(object sender, EventArgs e)
{
UsersBulletedList.DataSource = theContext.GetOnlineFavorites(4);
UsersBulletedList.DataBind();
}
public IQueryable<String> GetOnlineFavorites(int theUserID)
{
List<String> theUserList = new List<String>();
IQueryable<Favorite> theListOfFavorites= this.ObjectContext.Favorites.Where(f => f.SiteUserID == theUserID);
foreach (Favorite theFavorite in theListOfFavorites)
{
string theUserName = this.ObjectContext.SiteUsers.Where(su => su.SiteUserID == theFavorite.FriendID && su.LoggedIn == true).FirstOrDefault().UserName;
yourOnlineFavorites.Add("<a href='RealTimeConversation.aspx?UserName=" + theUserName + "'>" + theUserName + "</a>");
//this needs to help me get into a codebehind method instead of linking to another page.
}
return yourOnlineFavorites.AsQueryable();
}