mobileNavlogo
headerlogo

c# code in view

21 September, 2018

Ratings

Related Blogs

Integrating c# code in views

To integrity the C# code in a view we write the code complicity in source part of .asp x file by enclosing in server side decimeters’ <% C# code %> 2To write some C# code in index .asp x use the follows steps. Go to solution explorer

       ↓

Double click index.asp x from home folder of view

       ↓

Go to source of index .asp x

       ↓

Write the following code within the content place order   <Content-id> <br/> <% Response.write (‘welcome to MVC class’);%> <br/> <% Response.write (Date.time.now.to string1);% > <br/> <% for (int i=0; i<=10; i++) { Respons.write (“satya”); } %> </content>

Desired to gain proficiency on ASP.Net? Explore the blog post on ASP.Net training to become a pro in ASP.Net.

Example to create a view and calling in form browser Go to solution explore

       ↓

Go to select home folder from views

       ↓

Click with RM button

       ↓

Click on ADD

       ↓

Click on view

       ↓

Add view dialogue box will appear

       ↓

Type the view name (sample)

       ↓

Deactivate the check box select master page

       ↓

Click on add

       ↓

This will create a view with the name sample .asp x (no .cs file will be create)

       ↓

Go to source

       ↓

Write the following code <div> <h1>satya technologies</h> </div> 2Any view will create is a class which is inherited from system.web.MVC.view page class. To access this view from the web browser we can create an action method with the same name as view in home controller .cs file mandatorily. Go to home controller .cs file

       ↓

Write the following code Public action result example () { Return view (); } Run the application by default index page will appear to see the sample view you type in the address bar home/sample at the end of the address bar http:// local host: 1974 (application name)/Home (control name)/sample (action method name)

For indepth understanding click on
 

 

About Author
Authorlogo
Name

TekSlate

Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .