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

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

How do I insert into header section using Razor and layouts

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :ASP.Net


I'm learning MVC3 w/ Razor. I'm using layouts which I understand are equivalents of master pages in Web Forms.

I understand that @RenderBody is where the body content will go. In some cases, I need to insert something -- e.g. stylesheet reference or some jQuery code -- into header section but only for some pages. How do I do that?

View Complete Post

More Related Resource Links

question regarding displaying parameter value on the report header section



i have a tabular report which has 3 parameters.@begin date ,@enddate and @employeeid.the default value for the @employeeid parameter is "All" .the report works fine even if i don't enter any value for  the parameter @employeeid .

my question is:

i need to display the parameter value for the @employeeid in report header which is easy @parameter!employeeid.value

but I need to display "All" for @employeeid parameter in the report header even i don't enter any value for @employeeid 

i tried to do it by using the code below it is not giving me an error but it is not displaying "All" when i don't enter any value for the @employeeid parameter.


any help in this is greatly appreciated.



infopath repeating section only for insert new item not editable



i'm trying to use a repeating table in my form. where the user can only insert new item and not edit the existing items that are loaded in the form.

i have set the fields read only when they are not blank. but when the user wants to insert a new item and he makes a mistake he can not fix the field because it will be read only.

can some one help me with this.

i've been asking some question without getting help, hope someone can help me with this one

thnx in advance

Infopath: problem with structured layouts within a repeating section or table



I've run into a bit of a problem when trying to structure information in a repeating section or table.

What I need to be able to do is use a repeating section or repeating table to receive data from a secondary data source and then structure this data and have the ability to have the field names at the top of each row in the table.

Both options seem floored:

repeating table: this method seems ok at first but it doesn’t seem possible to have the field names at the top of each row, which is a requirement. 

repeating section: this does include the field names for each row but for some reason will not allow me to structure the fields in a nested table, so its messy.

Repeating section appears above when insert command clicked


I have a form containing a repeating section.  The section contains a number of control within a layout table.  The repeating section properties are set to allow users to insert a new section.  By default new rows/tables in repeating controls are inserted below the existing when the command line is clicked.

Is there a way to change this default, ie. when the command line is clicked the repeating section is added ABOVE the existing section? 

The form will be operationg as browser enabled within SharePoint (2005)

ASP.NET MVC 3: Layouts with Razor

Two weeks ago we shipped the ASP.NET MVC 3 Beta Release .  It supports "go live" deployments, and includes a bunch of nice improvements/enhancements.  You can see a summary of the new ASP.NET MVC 3 features in my beta announcement post .  Also read my original ASP.NET MVC 3 Preview post to learn about other ASP.NET MVC 3 features that showed up with that initial preview release. This is another in a series of "mini-posts" I'm doing that talk about a few of the new ASP.NET MVC 3 Beta features in more detail: New @model keyword in Razor (Oct 22nd) Layouts (this post) In today's post I'm going to discuss layout pages with Razor, and discuss some of the improvements to them that we introduced with the recent ASP.NET MVC 3 Beta. Razor...(read more)

Insert value using Table Value Functions

a real gem in Sql Server 2008. mostly people still using Stored procedure may be they shifted to SQL Server but they are not using TVF right now.

Insert Rows with a GridView

In ASP.NET version 1.x, I used the footer on the DataGrid control to insert new rows by placing a series of TextBox, DropDownLists, CheckBoxes etc. controls on it and then handling a save button. This also works with the GridView in version 2.0 but with one major exception: if your data source is empty, the GridView will hide your footer (and header) and only display the EmptyDataText.

Create ToolTip for GridView Header

The following allows you to add a tooltip to the header links of your GridView, a feature that is lacking.

Rendering ASP.NET Script References into the Html Header

One thing that I've come to appreciate in control development in ASP.NET that use JavaScript is the ability to have more control over script and script include placement than ASP.NET provides natively. Specifically in ASP.NET you can use either the ClientScriptManager or ScriptManager to embed scripts and script references into pages via code.

How to Fixed GridViews Header and Footer when scrolling in asp.net?

This article is to show you how to Fix GridView''s Header and Footer in a simple code with CSS and JavaScript

SqlCommand.ExecuteNonQuery() returns -1 when doing Insert / Update / Delete

Sometimes you end up with a return value of -1 when using the SqlClient.SqlCommand.ExecuteNonQuery method.

Why is that?

Well, the ExecuteNonQuery method is there for statements for changing data, ie. DELETE / UPDATE /INSERT, and the returned value are the number of rows affected by that statement.

When checking the documentation we can see that there are some conditions that return -1.

For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command.

When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of

rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.

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?

Insert Error not helpful



I am using VS2010

When I try to updated or insert a record in my User table I am getting an error that does not make sense to me and I cannot figure out what is wrong.

Also, when I try to insert a new record I get a validation error saying that the Id is required. However it is an identity field in the db so it should not be necessary to send it to the server.

Could you please shed some light?


An error has occurred.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Microsoft.Web.UI.WebControls.EntityOperationException: An error has occurred.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace:

[EntityOperationException: An error has occurred.]
   Microsoft.Web.UI.WebControls.DomainDataSourceView.PerformCudOperation(ChangeSetEntry operation, Action`1 operationPerformingEvent, Action`1 operationPerformedEvent) +331
   Microsoft.Web.UI.WebControls.DomainDataSourceView.UpdateObject(Object oldEntity, O

Detecting Edit or Insert Page


I am coding a .cs file that handles the metadata for a particular table. I am putting a custom validation that allows me to update or insert only if the PubMedID is not already in the database. This would be easy except that the PMID should also be allowed to be null as some of the references in the database were not from PubMed. So i perform a query on the database to see if there is already an identical PMID in the database. This works great when using Insert. However, when using Edit, it does not. The PMID is already in the database because the one currently being edited has the same PMID!!! So I know exactly how to change my query etc. However, I do not know how to tell from inside this Edit/Insert agnostic page, which one it is being called from. Thanks for your help! 

how To Insert the single quotes in sqlcommand in asp.net


Hi all

    i am developed on simple user registeration application in that i gave  address field .when i am trying to enter something like this (1st main,b'lore) but wont take while inserting.

my query is

sqlcommand cmd=new sqlcommand("insert into registeration_form(name,address)values('"+txtname.text+"','"+txt_address+"')",con);

how can i pass the  quotes also to my query please if any one know reply me.


G Dinakaran

Insert data to Excel using OLEDB



I am trying to insert data to Excel Document using OLEDB as follows:-

 sql = "Insert into [MyFirstSheet$] (" + Title1 + "," +Title2 + "," + Title3 + ") 
values('" + Value1 + "','" + Value2 + "','" + Value2 + "')";
myCommand.CommandText = sql;

 sql = "Insert into [MyFirstSheet$] (" + Title1 + "," +Title2 + "," + Title3 + ") 

values('" + Value1 + "','" + Value2 + "','" + Value2 + "')";

myCommand.CommandText = sql;


But, the Title1 ,Title2, Title3 are in the 3rd row of the Excel Document. So, the data is not inserted.

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