Register Blogs FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Go Back   DeveloperBarn Forums > Programming & Scripting > .Net Development

Sponsored Links

Discuss "Name 'this' is not declared." in the .Net Development forum.

.Net Development - Learn about the Microsoft.Net framework and how to create powerful web-based (ASP.net) and client-based (Windows Forms) applications utilizing various languages such as C#, VB.Net, J# and others.


Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old July 3rd, 2008, 08:55 AM
Shem's Avatar
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 263
Thanks: 31
Thanked 5 Times in 5 Posts
Rep Power: 1
Shem is on a distinguished road
Default Name 'this' is not declared.

I have this in my HEAD section:
Code:
<script language="JavaScript">
			function CallServerEvent(argument)
			{
				document.getElementById('<%=Hidden1.ClientID %>').value = argument;
				<%= Page.ClientScript.GetPostBackEventReference(this.Button1, "") %>
			}
		</script>
and i'm getting:
Code:
 Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'this' is not declared.

Source Error:

Line 11: 		{
Line 12: 			document.getElementById('<%=Hidden1.ClientID %>').value = argument;
Line 13: 			<%= Page.ClientScript.GetPostBackEventReference(this.Button1, "") %>
Line 14: 		}
Line 15: 	</script>


Source File: C:\Inetpub\wwwroot\keithdesign\main.aspx    Line: 13
ideas?
Shem
Reply With Quote
Sponsored Links
  #2  
Old July 3rd, 2008, 09:04 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 949
Thanks: 22
Thanked 93 Times in 90 Posts
Blog Entries: 6
Rep Power: 4
jmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the rough

Awards Showcase
Microsoft Windows Microsoft SQL Server Microsoft .Net Classic ASP 
Total Awards: 4

Default

JavaScript and C# use the 'this' keyword, but you placed it in VB.net code.

See this page: ClientScriptManager.GetPostBackEventReference Method (Control, String) (System.Web.UI)
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding

Reply With Quote
  #3  
Old July 3rd, 2008, 10:19 AM
Shem's Avatar
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 263
Thanks: 31
Thanked 5 Times in 5 Posts
Rep Power: 1
Shem is on a distinguished road
Default

"this" must change to "Me"

Reply With Quote
  #4  
Old July 3rd, 2008, 10:23 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 949
Thanks: 22
Thanked 93 Times in 90 Posts
Blog Entries: 6
Rep Power: 4
jmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the rough

Awards Showcase
Microsoft Windows Microsoft SQL Server Microsoft .Net Classic ASP 
Total Awards: 4

Default

Yeap....also, I believe what you were using before was deprecated in .Net 2.0..so I provided the link to the new method.
Reply With Quote
  #5  
Old July 4th, 2008, 03:54 AM
Shem's Avatar
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 263
Thanks: 31
Thanked 5 Times in 5 Posts
Rep Power: 1
Shem is on a distinguished road
Default

I only made he change i mentioned and it worked
Reply With Quote
  #6  
Old July 4th, 2008, 09:53 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 949
Thanks: 22
Thanked 93 Times in 90 Posts
Blog Entries: 6
Rep Power: 4
jmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the rough

Awards Showcase
Microsoft Windows Microsoft SQL Server Microsoft .Net Classic ASP 
Total Awards: 4

Default

Quote:
Originally Posted by Shem View Post
I only made he change i mentioned and it worked
Indeed, it will still work, but when there is an updated way of doing things, it is best to use it
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > .Net Development

Bookmarks

Thread Tools
Display Modes

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

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

Forum Jump


All times are GMT -4. The time now is 10:35 AM.



Content Relevant URLs by vBSEO 3.2.0