7 Replies - 2544 Views - Last Post: 15 June 2011 - 07:54 AM Rate Topic: -----

#1 bonkerspr  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 92
  • Joined: 05-December 08

Problems declaring a c# string variable inside a aspx file?

Posted 14 June 2011 - 03:25 PM

I have problems declaring a string type variable in c# inside the .aspx file

this is why i have inside the asp file:

 

		<%
		    String MailTo;
		    String MailFrom;
		    String MailSubject;
                 %>





But i am having error when compiling because the String class is not included. How to include this inside the aspx file ?
Is This A Good Question/Topic? 0
  • +

Replies To: Problems declaring a c# string variable inside a aspx file?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9210
  • View blog
  • Posts: 34,592
  • Joined: 12-June 08

Re: Problems declaring a c# string variable inside a aspx file?

Posted 14 June 2011 - 03:54 PM

Why would you need that in your aspx and not say in your code behind?
Was This Post Helpful? 0
  • +
  • -

#3 bonkerspr  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 92
  • Joined: 05-December 08

Re: Problems declaring a c# string variable inside a aspx file?

Posted 14 June 2011 - 04:20 PM

I dont want to use it on the code behind secction because goddady hosting is blocking some of the instrucctions in the code behind , thats why i am trying to put all code in the aspx web files.
Was This Post Helpful? 0
  • +
  • -

#4 souptoy  Icon User is offline

  • D.I.C Head


Reputation: 54
  • View blog
  • Posts: 244
  • Joined: 17-January 08

Re: Problems declaring a c# string variable inside a aspx file?

Posted 14 June 2011 - 04:34 PM

C# is case-sensitive...did you want the class or the type? String and string are two different things.
Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Problems declaring a c# string variable inside a aspx file?

Posted 14 June 2011 - 05:25 PM

View Postsouptoy, on 14 June 2011 - 07:34 PM, said:

C# is case-sensitive...did you want the class or the type? String and string are two different things.


String and string are not different(other than spelling). string is an alias for System.String. String is System.String. Both compile into the same code.

To the OP, make sure you have your using statements.
Was This Post Helpful? 0
  • +
  • -

#6 bonkerspr  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 92
  • Joined: 05-December 08

Re: Problems declaring a c# string variable inside a aspx file?

Posted 14 June 2011 - 07:39 PM

I need to decleare a stirng variable inside the aspx file, not on the code behind. i tried to do it in upper case and lower case but faild because i don know how to inclue the string class in the file.

for example in c++ we write #include <string>.


But on c# how i can do it inside the .aspx file ?

This post has been edited by bonkerspr: 14 June 2011 - 07:53 PM

Was This Post Helpful? 0
  • +
  • -

#7 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9210
  • View blog
  • Posts: 34,592
  • Joined: 12-June 08

Re: Problems declaring a c# string variable inside a aspx file?

Posted 14 June 2011 - 08:40 PM

Well if you must, then check out 'code blocks'. It matters greatly where they are placed.

http://msdn.microsof...y/f0111sbh.aspx

You need to throw in blocks like this for global:
<script runat="server">
</script>


This is for inside of your html blocks:
 <% ... %> 

Was This Post Helpful? 2
  • +
  • -

#8 souptoy  Icon User is offline

  • D.I.C Head


Reputation: 54
  • View blog
  • Posts: 244
  • Joined: 17-January 08

Re: Problems declaring a c# string variable inside a aspx file?

Posted 15 June 2011 - 07:54 AM

View Posteclipsed4utoo, on 14 June 2011 - 05:25 PM, said:

String and string are not different(other than spelling). string is an alias for System.String. String is System.String. Both compile into the same code.


Thanks for the correction. I could have sworn they were different. Now I know. :stupid:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1