DeveloperBarn Forums

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

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 « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old July 3rd, 2008, 08:55 AM
Shem's Avatar
Contributing Member

 
Join Date: Mar 2008
Posts: 192
Thanks: 24
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 (permalink)  
Old July 3rd, 2008, 09:04 AM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 537
Thanks: 14
Thanked 40 Times in 39 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead will become famous soon enough

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows 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
Did I help you out? Make me popular by clicking the icon!

If you found a post helpful, please click the button in the lower right-hand corner of the post.

Powered by ASP.Net
Reply With Quote
  #3 (permalink)  
Old July 3rd, 2008, 10:19 AM
Shem's Avatar
Contributing Member

 
Join Date: Mar 2008
Posts: 192
Thanks: 24
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 (permalink)  
Old July 3rd, 2008, 10:23 AM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 537
Thanks: 14
Thanked 40 Times in 39 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead will become famous soon enough

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows 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 (permalink)  
Old July 4th, 2008, 03:54 AM
Shem's Avatar
Contributing Member

 
Join Date: Mar 2008
Posts: 192
Thanks: 24
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 (permalink)  
Old July 4th, 2008, 09:53 AM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 537
Thanks: 14
Thanked 40 Times in 39 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead will become famous soon enough

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows 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


Sponsored Links

ASP.NET Resource Index
a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer.

Free Web Directory
Including Chats and Forums Resources, Offer automatic, instant and free directory submissions.
URLZ Web Directory
URLZ Web Directory

Free Web Directory - Add Your Link
The Little Web Directory
Free Web Directory
Pegasus free web directory is a free directory organised by categories.

Web Directory & SEO Services
dirroot web directory


All times are GMT -4. The time now is 08:59 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 2008 DeveloperBarn.com

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