Skip to main content

Posts

Showing posts with the label asp.net

Custom configuration in Web.config

Almost all projects have come configuration which is mostly unique and absolutely custom. That configuration allow to customize some application behaviors, settings and switching some parts of implementation. In Microsoft .NET Framework configuration can be stored in two types of files: *.config - XML based file which differ depending on project type. In web application such ASP.NET or WCF we working with Web.config file and in desktop application use App.config . *. setting - deprecated type of file which allow to store custom settings in XML  based, strongly typed file.  In this post I focus on Web.config file and demonstrate how to create custom section for this type of file.  At the beginning  we need some basic configuration file which is easy to get one because after we created new ASP.NET project from a template we already should have one. Simplified version on Web.config looks like as resented below. Code Snippet <? xml version = " 1.0 " ?>

MVC 3 Reload PartialView by using jQuery and AJAX

Sometimes it`s easier to reaload only part of the website witout reloading whole page. Thanks to AJAX technology such aproach is possible and easy to code. Let`s begin. Firstly we need to configure our environment so we must have a Visual Studio with MVC 3  Razor isntalled on it. Razor can be obtained from here . After installation process completed , the second step is to set up a new WebStie project (Picture 1.) Picture 1. After you confirm Your project type choise, next window starts. On it You should select the second web project type (with Forms autentication method)  and than choose RAZOR form dropdown (Picture 2.). Picture 2. Now You new web solution contains several folders and files by default. Their description is not a point of this article so allow myself to continue. Next step is to create a simple model for our PartialView. As an example I  created a simple _UserModel.cs in Models folder. The source code for this model is:  public class _UserModel     {