.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

Extending RAZOR

Posted By:      Posted Date: October 05, 2010    Points: 0   Category :ASP.Net
 

can you define function in a file and use it in another file ?

well , i managed to do it , but there may be an easiest way. I was able to define functions in _init , but not in the _start file :

@// _init.cshtml
@functions{

    string SaySomething()
    {
        return "Outside function calls work too !!!";
    }

}
@{


PageData["SaySomething"] =(Func<string>)SaySomething;
}


function call is simple : PageData["SaySomething"]()

but there may be a built in way and a way to declare functions in the APP_CODE folder in Razor syntax , isnt it ? (i'm full aware of C classes , but i wanted to try to do a 100% razor site , for study purposes )




View Complete Post


More Related Resource Links

Extending RAZOR (functions, classic asp, .cs)

  

Hi all,

First off... I really enjoy Web Matrix. I have already(very rapidly) created two locally host full fledged websites. These arent production ofcourse, but I was really impressed with how fast I was able to learn and build dynamic sites.

I want to learn more! I have some basic questions below;

  1. Can I call functions from a .cs to a .cshtml?
    Explained: Could I take an object oriented approach to RAZOR pages? If I were to create a class with some methods/functions/objects could I use them from my .cshtml?
    Does anyone have an example of this?

  2. Can I create functions inside a .cshtml page?
    Explained: Is this different from classic asp syntax?
    Should I be looking at classic asp syntax to learn more?

  3. If I wanted to create my own "helper" functions and/or add to the RAZOR api - is this something that is open?
    Explained: I'd love to be able to create my own set of "things" that I can continue to use in further projects?
    Yes? No?


  4. There are no clear examples or clear case usage of the html GET capability. Again, should I consider classic asp syntax for this?

  5. What will RAZOR be like down the road? Is there a goal?

Extending RAZOR

  

can you define function in a file and use it in another file ?

well , i managed to do it , but there may be an easiest way. I was able to define functions in _init , but not in the _start file :

@// _init.cshtml
@functions{

    string SaySomething()
    {
        return "Outside function calls work too !!!";
    }

}
@{


PageData["SaySomething"] =(Func<string>)SaySomething;
}


function call is simple : PageData["SaySomething"]()

but there may be a built in way and a way to declare functions in the APP_CODE folder in Razor syntax , isnt it ? (i'm full aware of C classes , but i wanted to try to do a 100% razor site , for study purposes )


Business Modelling and Web Applications and extending UML

  
UML can be used to model a business, prior to automating it with computers. The same basic UML syntax is used, however, a number of new symbols are added, in order to make the diagrams more relevant to the business process world. A commonly-used set of these symbols is available in current versions of Rational Rose.

Sending a File Using Email Helper in WebPages/Razor

  

Note: This is particularly with respect to Email Helper in WebPages/Razor. Please don't post links using System.Net.Mail object.

Following this tutorial: http://www.asp.net/webmatrix/tutorials/9-adding-email-to-your-website

Under "Sending a File Using Email" section what exactly is the code trying to do.

1: The SendFile.cshtml does not have any option to select file.

2: ProcessFile.cshtml is running fine. I am getting the email but no attachement.

I tried changing fileAttachment input to type="file" but not file is being sent to my email. I just get the message send in body.

Question: How exactly this file attachment works using Email Helper in WebPages.



How to configure IIS 7.0 for ASP.NET Web Pages Razor

  

I'm working on a blog framework using ASP.NET Web Pages with Razor Syntax and I'm having some trouble with URL rewrites. My server is a Windows Server 2008, which runs IIS 7.0. WebMatrix is already installed on the server and .cshtml pages runs without problems, as long as they are named "index.cshtml" I don't have to supply the extension.

What does not work, is when I have URLs that does not correspond to physical files, e.g. website/post/why where the only physical file I have is post.cshtml. With IIS Express, the post.cshtml file is execute but on IIS 7.0 I get a 404 error.

Should I install the URL Rewrite for IIS 7.0? What configuration changes is required?


Beyond MVP: Extending the MVP Pattern to Simplify UI Architecture

  

MVP has become a dominant pattern for UI design, but there are many interpretations of how to implement MVP. We take a look at some MVP-extending pattern and pull them into a holistic view of UI architecture.

Haozhe Ma

MSDN Magazine February 2010


Toolbox: Easy Web Debugging, Extending Reflector, and More

  

This month, a better design-time experience for Web apps, Scott Guthrie's blog, extending Extend Lutz Roeder's Reflector, and more.

Scott Mitchell

MSDN Magazine March 2008


Service Station: Extending WCF with Custom Behaviors

  

WCF extensibility points allow you to customize the process by which messages are translated, formatted, and sent over the wire for more customized services.

Aaron Skonnard

MSDN Magazine December 2007


Foundations: Extending the WPF Animation Classes

  

Learn what the WPF Animation Classes can do, what they can't, and how to extend them.

Charles Petzold

MSDN Magazine July 2007


Extending SDL: Documenting And Evaluating The Security Guarantees Of Your Apps

  

In this article, the author presents an extension to the Security Development Lifecycle Which could promote a better flow of information between users and designers of software security features.

Mark Novak

MSDN Magazine November 2006


Cutting Edge: Extending the GridView Control

  

Welcome to my100th consecutive installment of Cutting Edge. I've been writing this column since January 1998 in Microsoft Internet Developer. Looking back over the past eight years, I realize that I've touched on almost every subject in the Windows® SDK and the Microsoft® .

Dino Esposito

MSDN Magazine May 2006


CLR Inside Out: Extending System.Diagnostics

  

The System. Diagnostics namespace in the Microsoft® . NET Framework contains powerful tracing capabilities. This includes the main tracing API: TraceSource. As you will see, the tracing APIs in System.

Krzysztof Cwalina

MSDN Magazine April 2006


More Windows 2000 UI Goodies: Extending Explorer Views by Customizing Hypertext Template Files

  

The Web-style interface is the default Explorer folder view for the Desktop Update in Windows 2000. The Desktop Update uses HTML-based hypertext templates to create the Web view, and you can customize these templates to include your own views and commands. This article shows you how the Explorer Web view works and how to build your own custom templates for it. You'll see how to add a command prompt and task buttons to a new folder view using HTML, script, and ActiveX controls. The shell object model and thumbnail shell extensions are also examined, then used to build a simple icon viewer for Explorer.

Dino Esposito

MSDN Magazine June 2000


Razor and Visual Studio Intellisense

  

Hello,

I am using VS 2010 with MVC3 and Razor view engine but on the views when I write @... I never have intellisense.

Do I need to do something?

Thanks,

Miguel


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend