Output username to html

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

hi,

i'm trying to write out the currently logged on user with the
following code, however it doesn't write anything when run in the
browser.
any ideas?
thanks,

-----------------------------------------------------
public string test = "";

private void Page_Load(object sender, System.EventArgs e)
{
test += User.Identity.Name;
test += WindowsIdentity.GetCurrent().Name + " is the user";
}
 
Perhaps you may want to try an alternative to the old ASP <%= %> write tags. Try databinding tags <%# %> instead. This way, you can control when the string is written to the page by calling this.DataBind().

public string test = "";

private void Page_Load(object sender, System.EventArgs e)
{
test += User.Identity.Name;
test += WindowsIdentity.GetCurrent().Name + " is the user";
this.DataBind();
}

<div id="center"><%# test %></div>

Joe Agster
www.geekyfrog.com

----- Mark wrote: -----
public string test = "";

private void Page_Load(object sender, System.EventArgs e)
{
test += User.Identity.Name;
test += WindowsIdentity.GetCurrent().Name + " is the user";
}
hi,

i'm trying to write out the currently logged on user with the
following code, however it doesn't write anything when run in the
browser.
any ideas?
thanks,
 
thanks for the tip, but it still refuses to output the text from the
test variable to the page.

Tried setting a breakpoint in vs.net to see what was stored int he
variable but the debugger didn't break at that line.

Seems to not even execute the Page_load?
 
That page seems to be for asp, asp.net is ment to give you
User.Identity.Name; or WindowsIdentity.GetCurrent().Name; to get the
username, but both i've found have been doing doing nothing.

public string test ="is the user"; <-- will output "is the user"

however, the following outputs nothing, not even the "is the user" part
of the string. any ideas?
thanks,

-------
public string test = "";

------ on_page_load---------
test += User.Identity.Name;
test += WindowsIdentity.GetCurrent().Name + " is the user";
---------------------
 
Back
Top