Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Output username to html

 
Thread Tools Search this Thread
Old 02-04-2004, 11:34 PM   #1
Default Output username to html


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";
}
-----------------------------------------------------

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


Mark
  Reply With Quote
Old 02-05-2004, 12:11 AM   #2
=?Utf-8?B?Sm9lIEFnc3Rlcg==?=
 
Posts: n/a
Default RE: Output username to html
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,

-----------------------------------------------------

-----------------------------------------------------

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



=?Utf-8?B?Sm9lIEFnc3Rlcg==?=
  Reply With Quote
Old 02-05-2004, 01:20 AM   #3
Michael Pearson
 
Posts: n/a
Default Re: Output username to html
Take a look at this:

http://www.4guysfromrolla.com/webtech/092298-3.shtml

I think the way you are going about this will give you the user that ASP.net
is running as.

Michael
"Mark" <> wrote in message
news: om...
> 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";
> }
> -----------------------------------------------------
>
> <div id="center"><% = test %></div>
> -----------------------------------------------------



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.573 / Virus Database: 363 - Release Date: 1/28/2004




Michael Pearson
  Reply With Quote
Old 02-05-2004, 01:29 AM   #4
Mark -
 
Posts: n/a
Default RE: Output username to html
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?




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Mark -
  Reply With Quote
Old 02-05-2004, 04:59 AM   #5
Mark -
 
Posts: n/a
Default Re: Output username to html
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";
---------------------



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Mark -
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
CISCO 1801 DNS problem marsav Hardware 2 07-05-2009 11:41 PM
Different types of video output - I'm confused robotiser@googlemail.com DVD Video 2 07-29-2007 04:25 PM
Post-Route Simulation does not give output for the first clock cycle Options velocityreviews Software 0 04-17-2007 05:47 PM
Sony Precision Cinema Progressive Output vs Component 480p Output Otto Pylot DVD Video 1 04-18-2004 10:49 PM
Panasonic S25 DVD player w/o S-video output - will its replacement have S-video? Mark DVD Video 1 02-11-2004 04:19 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46