隐藏按钮和注释文本框... [英] Hide a button and Comments Text box...

查看:72
本文介绍了隐藏按钮和注释文本框...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我是ASP.NET MVC框架的新手.

我正在创建一个像Facebook这样的小型网站.

我有注册表和登录功能.显示数据库中存在的所有朋友(用户)的功能.
我做了一个功能添加为朋友.哪个人可以用来与另一个指定的人成为朋友. IT工作正常..但我需要从正在登录的用户的用户中隐藏此添加人.

像.. 3个人在列表中.马丁,尤纳斯,米凯尔.如果martin登录到网站并且他只有Younas作为朋友,那么我希望Younas名称前面的添加"按钮是invisibel.

我该怎么做,希望你能理解??? (就像Facebook的禁友名单)

第二个我需要评论框,我们可以在其中添加赞或状态,例如facebook或twittter?

请帮助我.

Hello,

I''m new to ASP.NET MVC framework.

I''m creating a small webssite like Facebook.

I have registration form and login function. A function which shows all friends(users) who are exist in database.
I made a function Add as Friend. Which person can use to make the other specifik person as a friend. IT works fine.. but I need to hide this Add person from those person who are users of the person who are login.

Like.. 3 person are in list. Martin, Younas, Mikael. IF martin is login to website and he had only Younas as a friend then I want that the Add button in front of Younas name is invisibel.

How can I do that hope u understand ??? (Like facebook frined list)

2nd I need Comment box where we can add commens or status like facebook or twittter??

please help me on that.

推荐答案

ASP.NET MVC,关键部分是 ASP.NET .如果要在页面(视图)上添加控件,请添加它.您到底有什么困难?
ASP.NET MVC, the key part is ASP.NET. If you want a control on the page (view) then add it. What part exactly are you having difficulty with?


如果有任何可能,我可以向您发送我的项目.它的make功能意味着我将visibel功能隐藏在什么地方以及我拥有什么编写功能.

Friendlist.cs
--------------
命名空间SocialNet.Domain.Entities
{
公共类FriendsList
{
私有列表< UserLine>行=新列表< UserLine>();
公共IList< UserLine>行{get {返回lines.AsReadOnly(); }}
公共无效AddItem(用户)

{
var line = lines
.FirstOrDefault(x => x.User.userID == user.userID);
如果(line == null)
lines.Add(new UserLine {User = user});
//else
//lines.Add(null);
}

}
公共类UserLine
{
公共用户用户{放; }
}
}

它的控制器:
................
公共类FriendsListController:控制器
{公共类FriendsListController:控制器
{
私有IUsersRepository usersRepository;
公共FriendsListController(IUsersRepository usersRepository)
{
this.usersRepository = usersRepository;
}
公共RedirectToRouteResult AddToFriendsList(FriendsList朋友列表,int userId,
字符串returnUrl)
{
用户用户= usersRepository.Users
.FirstOrDefault(p => p.userID == userId);
friendsList.AddItem(user);
return RedirectToAction("FriendsListPage",new {returnUrl});
}
{
返回视图(新的FriendsListViewModel
{
FriendsList = friendsList,
ReturnUrl = returnUrl
});
}
}

好友列表视图
---------------
]]>
]]>


]]>

此视图以行显示朋友列表..并具有添加到列表中的按钮.

if there is any posibility i can send u my project.. its the make functionality means where i put the hide of visibel functionaly and what i have to write in functionality.

Friendlist.cs
--------------
namespace SocialNet.Domain.Entities
{
public class FriendsList
{
private List<UserLine> lines = new List<UserLine>();
public IList<UserLine> Lines { get { return lines.AsReadOnly(); } }
public void AddItem(User user)

{
var line = lines
.FirstOrDefault(x => x.User.userID == user.userID);
if (line == null)
lines.Add(new UserLine { User = user });
//else
//lines.Add(null);
}

}
public class UserLine
{
public User User { get; set; }
}
}

its controller:
................
public class FriendsListController : Controller
{public class FriendsListController : Controller
{
private IUsersRepository usersRepository;
public FriendsListController(IUsersRepository usersRepository)
{
this.usersRepository = usersRepository;
}
public RedirectToRouteResult AddToFriendsList (FriendsList friendsList, int userId,
string returnUrl)
{
User user = usersRepository.Users
.FirstOrDefault(p => p.userID == userId);
friendsList.AddItem(user);
return RedirectToAction("FriendsListPage", new { returnUrl });
}
{
return View(new FriendsListViewModel
{
FriendsList = friendsList,
ReturnUrl = returnUrl
});
}
}

friendlist view
---------------
]]>
]]>


]]>

this view show the list of friends in lines.. and have the button which is add to list.

using(Html.BeginForm("AddToFriendsList", "FriendsList")){ %>
<![CDATA[<%: Html.HiddenFor(x => x.userID) %>]]>
<![CDATA[<%: Html.Hidden("returnUrl", Request.Url.PathAndQuery) %>]]>;
<![CDATA[<%: input type="submit"; value="Add as Friend" />
<% } %>]]>

Now question is how can i do is value Add as Friend to invisibel when its used by ones. and not apear as visibel to the who is already friend????????


这篇关于隐藏按钮和注释文本框...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆