-1

When using razor syntax in asp.net webpages On top of the index (or the default or what ever is the start) I can put some razor code that start with @{ }.

I have 2 or 3 classes in another folder, they have some methods that I will need for my web site to work. and here is my questions

Does all my code for my website go between this bracket in my index page on top of the html tags and from here I call classes and methods but every thing runs here?

or in within this brackets I send variables values to the classes that are in another folder they execute the methods and send back the result to index and then is posted in the html doc?

example

Project X
  Business Class folder
     Class Adding with method Sum()
     Class Grow with method Multiply()
  App Data folder
  Other Folders
  Index.cshtml
  About.cshtml

My index file where the app starts

    @{ Adding A = new Adding;
        int a=Sum();
        Grow B = new Grow;
        int b=Multiply();
     }
      <html>
       //use of a and b here
      </html>

As you can see the code in razor calls classes and methods that are in another folder. Question is: Does the code is executed only here in index? or when classes and method are called, the program goes to class Adding or Grow, execute the method and sends back the result to index?

can you point me to some info or tutorial?**

madhead
  • 31,729
  • 16
  • 153
  • 201
shark6552
  • 101
  • 1
  • 2
  • 12
  • 1
    Use asp.net mvc for separation – Mustafa ASAN Oct 05 '15 at 18:40
  • A great place to start is http://www.asp.net/get-started – jrummell Oct 05 '15 at 18:50
  • Guys are some of you so code snob that you can not answer a question of a person whos is learning? – shark6552 Oct 06 '15 at 14:19
  • Why some of you put this on hold and tagged as TOO BROAD when the question is clearly marked in black? – shark6552 Oct 06 '15 at 14:21
  • Hi Mason why the edition? just to know so Ican follow the rules if any about that – shark6552 Oct 06 '15 at 14:27
  • Welcome to SO. This site works a bit different then your regular forum. It is about clear-cut questions with clear-cut answers. Questions about asking for books, tutorials, learning material, tools etc are not "in scope" for this site. You can find more about this in the [help/on-topic], in [ask] and the [tour]. We don't mind helping beginners, if you show what you tried and where you are stuck (see [mcve]). The way your question is presently worded is too broad, but feel free to [edit] it and have it reopened. PS: I don't think writing in bold helps, as it is considered shouting by many. – Abel Oct 06 '15 at 15:00
  • thanks Abel I got, I never meant to shout, I edited my questios and put a small example I am still trying to sediment all this coding stuff in my mind – shark6552 Oct 06 '15 at 15:39

1 Answers1

0

If you want to call code from outside your .cshtml files then it must be either:

a) in the App_Code folder; or

b) compiled and in the bin folder.

So in your example, your Business Class folder should be inside the App_Code folder.

johna
  • 10,540
  • 14
  • 47
  • 72