Skip to main content

Posts

ASP.NET MVC Learning 3 : Global.asax File

The Global.asax file is called as the ASP.NET application file, which contains the events related to Application and Session level The file will be positioned in the root level of the Web Application. Adding this file to the application is not mandatory, if you want to handle the Application events or session events then you can use the file The following are the events available in the file,         protected void Application_Start( object sender, EventArgs e)         {            // Triggered when the application starts, the logs to the event handler, initializing singleton objects may be written here         }         protected void Session_Start( object sender, EventArgs e)         {         }         protected void Application_BeginRequest( object sender, EventArgs e)         {         }         protected void Application_AuthenticateRequest( object sender, EventArgs e)         {         }         protected void A

ASP.NET MVC Learning 2 : Routing Basics

ASP.NET Routing in ASP.NET MVC  is the concept of mapping the incoming request (URL) with the existing resources  For Example :  The incoming request URL for a local application is http://localhost:2233/home/index In the Application say we have configured the routing as "{controller}/{action}/{id}", so Home is the controller here and index is the action here, the id is optional in most cases, if id is not given then it will display the default value In ASP.NET MVC the controllers should have the naming convention, in this case the controller's name should be Home Controller, should end with 'Controller' suffix. The Routing mechanism looks in the HomeController for the Action that we set already, Here Home is Controller and the Action is Index In the Home Controller we will return the View (That is Index) as Action Result Sample Home Controller public class HomeController : Controller { public ActionResult Index ( ) { return V

ASP.NET MVC Interview Questions Part 1

1) What is MVC generally? M - Model  --> Contains Data and information on how to handle data (Business Logic) V - View --> Representation of data to the user (User Interface, Front End) C - Controller --> Sits between the Model and View, acts as interface between them, basically the controller takes the user request and provide the view with correct model data   This is software developing pattern which implements Seperation of Concerns (SoC), which decouples all the three components to enable it for better parallel programming, 2) What are the Advantages of MVC pattern Easy and Fast Development of code More meaningful URLs which provides the competetive edge over traditional URLs  Change Friendly Maintenance Friendly Test Friendly (Test Driven Development is fully supported) Easy to divide the application and respective teams such as Design Team, Developent Team, Database Team can collaboratively work 3) What is the current stable version of ASP.NET M

New feature in .NET 4.0 : Optional parameters -- Step by Step to Advanced -- Part 1

Optional Parameters: .NET introduced a new feature called Optional parameters in the version 4.0, where you can leave a particular parameter in the calling method and CLR will automatically assign the default value (That you need to provide prior) Example: Let's have a Console Application to discuss this,     class Program     {         static void Main(string[] args)         {             MyClass myclass = new MyClass();             myclass.MyMethod();             Console.ReadLine();         }     }     class MyClass     {         public void MyMethod()         {             Console.WriteLine("In MyMethod - No Parameters");         }     } Output: In MyMethod - No Parameters Adding one more MyMethod with a single int parameter         public void MyMethod(int a = 10)         {             Console.WriteLine("In MyMethod - Single Parameters");         } Then calling        

To change the background color or to change the inner text of a item in dropdown

To change the background color or to change the inner text of a item in dropdown // Loop around the dropdown for (row = 0; row < ddlUserName.Items.Count; row++) { // To color a particular user name if (ddlUserName.Items[row].Value == this.USERID.ToString()) ddlUserName.Items[row].Attributes.Add("style", "background-color:" + "#663333;color:#ffffff;"); }

Gridview headertemplate with checkbox and client side ( javascript) handling of select all / unselect all

Gridview headertemplate with checkbox and client side handling of select all / unselect all using javascript. courtesy from http://dotnetslackers.com/Community/blogs/kaushalparik/archive/2008/07/16/checkbox-in-headertemplate-to-select-all-checkboxes-inside-a-gridview-using-javascript.aspx Idea and code from this site, I enhached and made small corrections this for my application, according to my requirement Thanks to http://dotnetslackers.com/ for all the code.         <div>         <input type="hidden" id="hdnCheckBoxValue" />             <table>                 <tr>                     <td style="width: 100px;">                         <asp:GridView ID="gvVendorBulletin">                             <Columns>                                 <asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle"                            

Dynamically add CommandField of type Image to a gridview or any container.

Dynamically add CommandField of type Image to a grid or any container. if (!IsPostBack) { CommandField ImageCommand = new CommandField(); ImageCommand.ButtonType = ButtonType.Image; ImageCommand.DeleteImageUrl = "~/images/delete.gif"; ImageCommand.ShowCancelButton = false; ImageCommand.ShowDeleteButton = true; GridView1.Columns.Add(ImageCommand); } Then do the normal protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { } to delete or change as per your requirements.

To get the email addresses from aliases names : Outlook Programming using C#

Breach of Trust To get the email addresses from aliases names : Outlook Programming using C# IDE : Visual Studio 2008 Please ignore inappropriate content as put entire code since I am adding some more functionality other than finding the address through aliases names. using System; using System.Collections.Generic; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Microsoft.Office.Interop.Outlook; using System.Runtime.InteropServices; using System.IO; using ObjOutlook = Microsoft.Office.Interop.Outlook; namespace Stmp_Client_2008 { public partial class Form1 : Form { public String MailsSub; public String Cc; public String To; public String Bcc; public String SenderMailAddr; private static ArrayList emailCollection = new ArrayList(); public static Boolean SuccMail = false; public static Boolean MailFlag = false; ObjOutlook.Applicati

To create a User Control for add new rows dynamically using JavaScript, Asp.net, C#

User Control Code AddMore.ascx <% @ Control Language ="c#" Inherits ="Ind.UC.AddMore" CodeFile ="AddMore.ascx.cs" %> < table cellpadding ="0" cellspacing ="0" width ="100%" align ="center" id ="tblAddMore"> < tr > < td align ="right"> < input class ="button" id ="btnAdd" type ="button" value ="Add Row" runat ="server"> < input class ="button" id ="btnDelete" type ="button" value ="Delete Row" runat ="server"> td > tr > < tr style ="display:none"> < td align ="right"> < input class ="button" id ="btnGet" type ="button" value ="Get Values"