OK i understand that the question is not that specific but i will explain. I work on a website that where people can vote about specific questions on what is important to them and they can also comment after they wrote their thoughts. the problem is, people can like the comments other people give, and I'm not talking about liking with Facebook, since people have to sing up to use the site, i've created a button and a function for liking. but once you have liked a comment you cannot like it again, and there's no unlike. and if you hit like again a msgbox shows up that tells you that you have already liked this. now the problem is that, if you like it once, the url of the site changes when the msgbox appears and when you even try to like something else, or try to vote, it shows the msgbox that "you have already liked this!"
之前 的网址:http: //www.somesite.com/home/boduvanje? opstina_id=35 之后 的网址: http ://www.somesite.com/home/boduvanje?opstina_id=35&odgovor_id=28
对冗长的描述感到抱歉,但我认为更多的话会有所帮助。
继承人类似的功能:
public ActionResult boduvanje(int opstina_id, int odgovor_id)
{
Session["id_momentalno"] = opstina_id;
var ops = Convert.ToInt32(Session["id_momentalno"]);
var log = Convert.ToInt32(Session["logiran"]);
ViewData["log"] = log;
if (log == 1 )
{
int users_id = mor.FindUser_IdByUserName(Session["userName"].ToString());
if (mor.FindRezultatIdByUserId(users_id) & mor.FindRezultatIdByOdgovorId(odgovor_id))
{
Response.Write("<html><div id='msg1' onclick='message();'><div class='response' id='response_msg'>Веќе сте лајкнале! Немате право повторно !</div></div></html>");
var lista = mor.FindAllData(opstina_id).ToList();
return View("About", lista);
}
else
{
rezultati rez = new rezultati();
rez.opstina_id = opstina_id;
rez.odgovor_id = odgovor_id;
int id = mor.FindUser_IdByUserName(Session["userName"].ToString());
rez.user_id = id;
mor.AddRezultati(rez);
mor.Save();
var lista = mor.FindAllData(opstina_id).ToList();
return View("About", lista);
}
}
else
{
Response.Write("<html><div id='msg1' onclick='message();'><div class='response' id='response_msg'>Не сте логирани !</div></div></html>");
var lista = mor.FindAllData(opstina_id).ToList();
return RedirectToAction("LogOn", "Account");
}
}
按钮所在的asp文件中的代码如下:
<div class="like_button" id= "like_button" ><a href="/home/boduvanje?opstina_id=<%:Session["opstina_id"]%>&odgovor_id=<%: tcm.odgovor_id %>"><img src="/images/btn_dopaga.png" alt="like" /></a></div>
提前谢谢你,告诉我是否应该发布更多信息或其他内容:)