It's still not working. Whenever I try to make it so that when the page loads a text box in formview (set to insert mode by default) contains User.identity.Name it says that the textbox isn't declared.
Yes the problem is the textbox declaration as outside the formview it is fine. How do you declare textboxes in a formview or any other data web control?
Yes the problem is the textbox declaration as outside the formview it is fine. How do you declare textboxes in a formview or any other data web control?
Hi , you have not able to assign the User.Identity.Name to inside the
FormView, because its a Data Control, its not like textbox , label ,etc... (ie: Normal control) so you have to use SqlDatasource and pass the username to Texbox.
lewisbasham1...
Member
4 Points
34 Posts
inserting user.identity.name into the textbox of a formview
May 19, 2009 07:46 AM|LINK
Hello
I need to be able to insert the User.Identity.Name into a textbox of a formview control when the page loads for insertion into the database.
When I type the name of the Textbox, it says it is not declared.
What can I do to solve this?
Lewis
venkatu2005
All-Star
32487 Points
6742 Posts
Re: inserting user.identity.name into the textbox of a formview
May 19, 2009 07:53 AM|LINK
Hi, on page load try to assign the User.Identity.Name on some public variable then, pass the variable to the textbox. else post your code..
Thanks.
lewisbasham1...
Member
4 Points
34 Posts
Re: inserting user.identity.name into the textbox of a formview
May 19, 2009 08:33 AM|LINK
hi
Thanks for the reply.
I have tried using a variable but when it try to insert the value into the textbox in the formview it still says it is undeclared.
Lewis
pankajgohel
Participant
1274 Points
289 Posts
Re: inserting user.identity.name into the textbox of a formview
May 19, 2009 08:52 AM|LINK
Look into your .aspx.designer.cs file that you Textbox control is diclare or not
if it is not diclare than remove textbox control from aspx file and drag and drap new textbox control
Pankaj Gohel
Please Mark as Answer if you find the post useful.
lewisbasham1...
Member
4 Points
34 Posts
Re: inserting user.identity.name into the textbox of a formview
May 19, 2009 09:55 AM|LINK
Hi
It's still not working. Whenever I try to make it so that when the page loads a text box in formview (set to insert mode by default) contains User.identity.Name it says that the textbox isn't declared.
Lewis
venkatu2005
All-Star
32487 Points
6742 Posts
Re: inserting user.identity.name into the textbox of a formview
May 19, 2009 10:17 AM|LINK
I think the textbox declaration is a problem else try to check the code on outside the Formview, whether its working or not..
Thanks.
lewisbasham1...
Member
4 Points
34 Posts
Re: inserting user.identity.name into the textbox of a formview
May 19, 2009 10:52 AM|LINK
Hi
Yes the problem is the textbox declaration as outside the formview it is fine. How do you declare textboxes in a formview or any other data web control?
Thanks
Lewis
venkatu2005
All-Star
32487 Points
6742 Posts
Re: inserting user.identity.name into the textbox of a formview
May 19, 2009 11:10 AM|LINK
Hi , you have not able to assign the User.Identity.Name to inside the FormView, because its a Data Control, its not like textbox , label ,etc... (ie: Normal control) so you have to use SqlDatasource and pass the username to Texbox.
ex: www.asp.net/Learn/Data-Access/tutorial-49-vb.aspx
Thanks.
avicool08
Member
710 Points
272 Posts
Re: inserting user.identity.name into the textbox of a formview
May 19, 2009 11:23 AM|LINK
Try this:
HttpContext.Current.User.Identity.Name
or
System.Web.HttpContext.Current.User.Identity.Name
example: String getusername = HttpContext.Current.User.Identity.Name;
Abinash Tumulu
Please mark my reply as an
answer
if it helps.
Visit my blog .net Scanner
lewisbasham1...
Member
4 Points
34 Posts
Re: inserting user.identity.name into the textbox of a formview
May 19, 2009 11:34 AM|LINK
Hi
Thanks for the reply
I know about the User.Identity. I need to know how to insert this into a textbox on a formview
Lewis