开发者

User authenticated before enable dropping something

This is my first post here. I'm learning ASP.NET MVC3 and JQUERY together. For my learning, I created an interface like gmail where I have a treeview on the right of the page showing some labels to the user. On the rest of the page (r开发者_如何学编程ight part), I have a table showing some tabular data. I manage drag'n drop of labels (tags if you prefer) from the treeview to a specific row in the table. Everything works but I need to be sure the user is authenticated before allowing him to perform a drag'n drop of a label on a row of the table.

Below is my code:

$(".droppable").droppable({ hoverClass: "hover-row", drop: function (event, ui) {

   if ('<%= Context.User.Identity.Name %>' == "") { alert(Please connect!'); }
   ...
   ...

I'm sure this is not the best way to proceed. Something with IsAuthenticated may be better? Can you help me? I would like to alert the user if he try to drop something on a row when he is not connected.

Thank you for your help.


Here's a decent article on forms authentication in MVC: http://mikehadlow.blogspot.com/2008/03/forms-authentication-with-mvc-framework.html

Basically one way to do this would be:

<% if (!Context.User.Identity.IsAuthenticated) { %>
  <script>alert('Please connect!');</script>
<% } %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜