aspx Tutorial

.NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services, .NET articles, Sharepoint 2010, visual studio 2010,Aamir Hasan,IT, Building Your First Web Application Project
Advertise Here

Toolbar

Get our toolbar!

Advertize



{#advanced_dlg.about_title}
by Aamir Hasan   on Thursday, March 10, 2011
Most of developers don't know that where to use SET NOCOUNT { on | off }. More
{#advanced_dlg.about_title}
by Aamir Hasan   on Wednesday, November 17, 2010
Several times,this question has been asked that how to print a page in Silverlight, thanks to Microsoft who  have given this print support in Silverlight 4. Before going to start you must have installed Visual Studio 2010 and Silverlight 4.Let’s start. Open your Visual Studio 2010, from File -> New Project -> Select Silverlight template -> give a name and click OK button to continue. Following is the code of  Main.xaml file.<UserControl x:Class="Silverlight4_Printing.MainPage"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    mc:Ignorable="d"    d:DesignHeight="400"  d:DesignWidth="560" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">    <Grid x:Name="LayoutRoot" Background="White" HorizontalAlignment="Center">        <sdk:Label Height="28" HorizontalAlignment="Left" Margin="10,10,0,0" Name="label1" VerticalAlignment="Top" Width="297" />        <Button Content="Print" Height="23" HorizontalAlignment="Left" Margin="66,103,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />    </Grid></UserControl>Following is the code of  Main.xaml.cs file        public MainPage()        {            InitializeComponent();            label1.Content = "Welcome to aspxtutorial.com";        }        private void button1_Click(object sender, RoutedEventArgs e)        {            var document = new PrintDocument();            document.PrintPage += (s, args) =>            {                args.PageVisual = LayoutRoot; args.HasMorePages = false;                button1.Visibility = Visibility.Collapsed;            };            document.EndPrint += (s, args) =>            {                button1.Visibility = Visibility.Visible;            };            document.Print("Silverlight Print Page");        } Output Download Silverlight 4 - Printing page.zip (252.13 kb) See live demo
{#advanced_dlg.about_title}
by Aamir Hasan   on Tuesday, November 2, 2010
In this example, I have demonstrate, how to Split a string using Linq query... More
{#advanced_dlg.about_title}
by Aamir Hasan   on Tuesday, November 2, 2010
how to get all Files list from a specific directory using Linq query... More
{#advanced_dlg.about_title}
by Aamir Hasan   on Tuesday, September 14, 2010
Yesterday, I got the error message “operation is not valid due to the current state of the object“ when I was adding web reference in my project. So, I decided to share with you. There are several reasons Is your web service running? Something wrong in your URL You have also put web service assembly into your server Global Assembly Cache. Restart your IIS If you have more solution, post here to share with us.
{#advanced_dlg.about_title}
by Aamir Hasan   on Tuesday, September 14, 2010
Yesterday some one ask me, how can i count a vowels from a string in MS SQL 2008.Here is the following SQL function to return count of vowels from a given input string. User defined function CREATE FUNCTION COUNT_VOWEL ( @STRING NVARCHAR(MAX) ) RETURNS INT AS BEGIN DECLARE @I INT DECLARE @COUNT INT SET @COUNT = 0 SET @I = 1 DECLARE @ANS NVARCHAR(MAX) DECLARE @VOWEL NVARCHAR(6) SET @VOWEL = 'AEIOU' WHILE @I <= LEN(@STRING) BEGIN SET @ANS = SUBSTRING(@STRING, @I, 1) IF @ANS = 'A' OR @ANS = 'I' OR @ANS = 'O' OR @ANS = 'U' BEGIN SET @COUNT = @COUNT + 1 END SET @I = @I + 1 END RETURN @COUNT END     Queries SELECT DBO.COUNT_VOWEL('AAMIR HASAN') AS [VOWELS(S)] SELECT DBO.COUNT_VOWEL('MAHWISH HASAN') AS [VOWELS(S)] SELECT DBO.COUNT_VOWEL('SABA KHAN') AS [VOWELS(S)] SELECT DBO.COUNT_VOWEL('BILL GATE') AS [VOWELS(S)] SELECT DBO.COUNT_VOWEL('CYNDY KRYSTYN') AS [VOWELS(S)] Output Download You can download source code from Here.
{#advanced_dlg.about_title}
by Aamir Hasan   on Sunday, July 11, 2010
Word Warp is the automatic breaking of text across lines. Text in a line automaticlly moves to the next line when length exceeds the postion of the right indent marker. If you are writing a query and if it exceed the length of the right indent marker then it will automatically shift to next line. To trun on the word warp in MS SQL 2008, open your MS SQL 2008 , at top menu of MS SQL 2008  click Edit -> click Advanced and then click Word Warp as shown in below figure , to turn off the Word Warp, click Word Warp.
{#advanced_dlg.about_title}
by Aamir Hasan   on Tuesday, July 6, 2010
Input logic, business logic, and UI logic is called MVC. MVC is designed on following three attribute. M (model), V (View), C (controller) as you see in Below Diagram.  Model: To build a model with business rules, validation and aggregation logic is called Model. For Example, Linq to SQL.dbml files. View: UI of asp.net Application is called View. For Example, Home, Account, Shared three folders in View Folder in this Project. In the Account folder is used for UI for logging and change password. Controller: Logic of application is called Controller. For Example, In this Project Controller folder includes AccountController and HomeController files which contains the  flow of login information  ASP.NET MVC 2 builds on ASP.NET MVC 1.0. MVC 2 can be used with asp.net 3.5 SP1 and With ASP.NET 4.O. MVC 2 by default installed on your computer when you install Visual Studio 2010. You can download latest version of MVC from MVC download page.In ASP.NET MVC 2 improves the maintainability of the application. You can Update asp.net MVC 1.0 protect to ASP.NET MVC 2. ASP.NET MVC2 introduces new features. New Features Template Helper to use Lambda Expression. Asynchronous Controllers for parallel long running tasks and  enable to Asynchronous Operations Matter Area to split large project to avoid the complexity of the large project. Right Click on your Project in the Solution Explorer, click Add and then click Area. Now you can add forum or admin in the Area Strongly Typed UI Helpers to view model level error instead of all validation Errors. HiddenInputAttribute Class for Templated Helpers when DisplayValue is false nothing will be happen but when DisplayValue is true then input hidden element will be rendered when  displaying model  in editor template Enhancements to ModelBinders Automatic HTML-Encoding Enhancements to ModelBinders supports are: Increasing Security with HTTPS Avoiding the JSON Array Attack Short Notation for AcceptVerbs Attribute Overriding the HTTP Verb Binary Binding Ability to render subsections of site pages   Example Open your Visual Studio 2010. Create New Project, window will be display on your screen, by default .Net Framework 4 is selected. Expand Visual C# and click on Web. Select ASP.NET MVC 2 Web Application as you see in below figure. Unit Test If you want to create Unit Test then select Yes option and give the Test Project name. By default name of the test project is the application project MvcApplication.Tests. You can change the name of project as shown in below figure.     Solution Explorer Project is created as you see in the below Figure. Content folder includes CSS file, Script contains js Files. You have three main folders Controller, Models and Views Controller Below is the Simple HomeController class. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace MvcApplication.Controllers { [HandleError] public class HomeController : Controller { public ActionResult Index() { ViewData["Message"] = "This is my First MVC Web Project"; return View(); } public ActionResult About() { return View(); } } } Views (Index.aspx Page) Here is the Code of index.aspx Page<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">    <h2><%: ViewData["Message"] %></h2>    <p>        To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.    </p></asp:Content>   Global.asax.cs Default created MVcApplication class in Global.aspx.cs file as shown in below code.   using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; namespace MvcApplication { // Note: For instructions on enabling IIS6 or IIS7 classic mode, // visit http://go.microsoft.com/?LinkId=9394801 //Author:Aamir Hasan public class MvcApplication : System.Web.HttpApplication { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); } } }   Unit-test project you will add a controller with an action method and a view, and you will add a unit test for the action method. Explorer View  Compile and run the Project and you will see Result in the Explorer   Download Mvc2Application.rar (47.36 kb)  
Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5