ddscart
  •  ddscart
  • 88.4% (Honored)
  • YAF Lover Topic Starter
2010-10-08T01:42:36Z
I am looking for a way to get the users name that is logged on. I want to use it in other ways. I am not a C++ programmer so it needs to be simple!

I thought maybe in default.aspx or in forum.aspx I could enter code something like this;

<textarea type=”hidden” value=”user” /> : Just simple html.

I could then use JavaScript to get the users name for my reasons.

Of course the variable “user” would have to be assigned. I assume by using some C++ code. Is there a simple line or two of code I could add without having to compile?

I am using version 1.9.1.8 (NET v2.0)

Any help would be appreciated.

www.ddscart.orgUserPostedImageddscart@ddscart.org
Disabled Dachshund Society of Georgia
Sponsor
ddscart
  •  ddscart
  • 88.4% (Honored)
  • YAF Lover Topic Starter
2010-10-08T13:39:16Z
I believe a login cookie is created when a user logs in, does anyone know what file I can find the code for this? Or maybe the cookie name?

I may be able to use the cookie to gain the info I need.
www.ddscart.orgUserPostedImageddscart@ddscart.org
Disabled Dachshund Society of Georgia
Jaben
  •  Jaben
  • 100% (Exalted)
  • YAF Developer
2010-10-08T19:54:16Z
System.Web.HttpContext.Current.User.Identity.Name will do the trick.
ddscart
  •  ddscart
  • 88.4% (Honored)
  • YAF Lover Topic Starter
2010-10-08T20:49:50Z
Thanks my friend, I will look at that tonight!
www.ddscart.orgUserPostedImageddscart@ddscart.org
Disabled Dachshund Society of Georgia
ddscart
  •  ddscart
  • 88.4% (Honored)
  • YAF Lover Topic Starter
2010-10-13T12:46:23Z
First, thanks for your response!

Clearly I don't understand something. I put the script in red in "forum.aspx" in attempt to make the logged in user appear in the input text box. I've tried all kinds of syntax, <,%," and such with no results.

If you look at my website, you will see a text box just above the chatbox. I'm trying to make the username appear there.

The smiley in the code should be a ), but it won't go away!

Any ideas?

<%@ Control Language="c#" Codebehind="forum.ascx.cs" AutoEventWireup="True" Inherits="yaf.pages.forum" %>
<%@ Register TagPrefix="yaf" Src="../controls/ForumList.ascx" TagName="ForumList" %>
<%@ Register TagPrefix="yaf" Namespace="yaf.controls" Assembly="yaf" %>

<script type="text/javascript">
var me="%System.Web.HttpContext.Current.User.Identity.Name%";
document.getElementsByName("namTxt").value = me;
</script>
<input type="text" name="namTxt" />

www.ddscart.orgUserPostedImageddscart@ddscart.org
Disabled Dachshund Society of Georgia

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved