Microsoft Dot Net Master

Microsoft Dot Net Master
Microsoft Dot Net Master

Saturday, April 16, 2011

Use full Links

********************code Library**************************
http://www.java2s.com/Code/ASP/CatalogASP.htm
http://www.m6.net/resources/asp.net_source_code.aspx
**********************************************************

******************Interview Question**********************
http://interviews.c-sharpcorner.com
http://www.siteadvisor.com/
http://www.dotnetfunda.com/interview/showcatquestion.aspx
http://www.daniweb.com/forums/thread149988.html#
**********************************************************



**************PDF Convertor****************
http://www.pdfonline.com/pdf2word/index.asp
*******************************************


********************Nested Query************************************************
http://www.codeproject.com/KB/database/nestedsets.aspx?msg=909894
********************************************************************************

*********************Database Synchronization*********************************
http://software.intel.com/en-us/articles/data-synchronization-which-technology/
******************************************************************************


************************.NET Architecture****************************************************
http://weblogs.asp.net/bsimser/archive/2006/08/13/3_2D00_tier-Architecture-wtih-ASP.NET-2.0.aspx#
http://www.aspdotnetcodes.com/Easy_Data_Binding_Accordion_GridView.aspx
http://forums.asp.net/t/1147715.aspx
http://www.codeproject.com/KB/applications/JumpyForum.aspx
******************************************************************************

********************Gurgaon Consultant*********************
http://www.naukri2000.com/careers/consultant_gurgaon.php3
**********************************************************


*****************Web Services******************
http://www.devx.com/dotnet/Article/20369/0/page/4
***********************************************

**************************Email Varification***********************************
http://my-addr.com/free-email-verification-tool/verify-email-address/reverse-email-lookup/verify_email.php?mail=ams@caryaire.com&x=15&y=10
******************************************************************************************************************************



***************Dictionary*******************************
http://virtualsalt.com/vocablst2.htm
********************************************************



********************WCF***********************
http://www.wcftutorial.net/WCF-Architecture.aspx
http://www.csharpkey.com/aspnet/index.htm
*************************************************



*************************Sqlserver Trigger*******************
http://msdn.microsoft.com/en-us/library/ms189799.aspx
*************************************************************


*************************Film Production Templates***************
http://templates.entheosweb.com/template_number/25353.asp
*****************************************************************
*****************************************************************
http://www.cafepress.com/cp/customize/makeadesign.aspx?clear=true&no=2#designer
*****************************************************************



************************* webserives**********************************
http://msdn.microsoft.com/en-us/magazine/cc163837.aspx
******************************************************

Send Email Using CDO

'If you have a GMail account then you can try this example to use the GMail smtp server
'The example will send a small text message
'You must change four code lines before you can test the code

'.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Full GMail mail address"
'.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "GMail password"

'Use your own mail address to test the code in this line
'.To = "Mail address receiver"

'Change YourName to the From name you want to use
'.From = """YourName"" "

'If you get this error : The transport failed to connect to the server
'then try to change the SMTP port from 25 to 465

Sub CDO_Mail_Small_Text_2()
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
Dim Flds As Variant

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Full GMail mail address"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "GMail password"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With

strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"

With iMsg
Set .Configuration = iConf
.To = "Mail address receiver"
.CC = ""
.BCC = ""
' Note: The reply address is not working if you use this Gmail example
' It will use your Gmail address automatic. But you can add this line
' to change the reply address .ReplyTo = "Reply@something.nl"
.From = """YourName"" "
.Subject = "Important message"
.TextBody = strbody
.Send
End With

End Sub

Sunday, April 10, 2011

Difference between 3-tier architecture and MVC in ASP.Net?

At first glance, the three tiers may seem similar to the MVC (Model View Controller) concept; however, topologically they are different. A fundamental rule in a three-tier architecture is the client tier never communicates directly with the data tier; in a three-tier model all communication must pass through the middleware tier. Conceptually the three-tier architecture is linear. However, the MVC architecture is triangular: the View sends updates to the Controller, the Controller updates the Model, and the View gets updated directly from the Model.

ASP.NET MVC (Model View Controller) Architecture

Introduction

This article is intended to provide basic concepts and fundamentals of ASP.NET MVC (Model View Controller) architecture workflow for beginners.
“M” “V” “C” stands for “MODEL” “VIEW” “CONTROLLER”. ASP.NET MVC is an architecture to develop ASP.NET web applications in a different manner than the traditional ASP.NET web development. Web applications developed with ASP.NET MVC are even more SEO (Search Engine) friendly.
Developing ASP.NET MVC application requires Microsoft .NET Framework 3.5 or higher.

MVC Interaction with Browser

Like a normal web server interaction, MVC application also accepts requests and responds to the web browser in the same way.


Inside MVC Architecture

The entire ASP.NET MVC architecture is based on Microsoft .NET Framework 3.5 and in addition uses LINQ to SQL Server.

What is a Model?

  1. MVC model is basically a C# or VB.NET class
  2. A model is accessible by both controller and view
  3. A model can be used to pass data from Controller to view
  4. A view can use model to display data in page.

What is a View?

  1. View is an ASPX page without having a code behind file
  2. All page specific HTML generation and formatting can be done inside view
  3. One can use Inline code (server tags ) to develop dynamic pages
  4. A request to view (ASPX page) can be made only from a controller’s action method
What is a Controller?
  1. Controller is basically a C# or VB.NET class which inherits system.mvc.controller
  2. Controller is a heart of the entire MVC architecture
  3. Inside Controller’s class action methods can be implemented which are responsible for responding to browser OR calling views.
  4. Controller can access and use model class to pass data to views
  5. Controller uses ViewData to pass any data to view 

MVC File Structure & File Naming Standards

MVC uses a standard directory structure and file naming standards which are a very important part of MVC application development.
Inside the ROOT directory of the application, there must be 3 directories each for model, view and Controller.
Apart from 3 directories, there must have a Global.asax file in root folder, and a web.config like a traditional ASP.NET application.
  • Root [directory]
    • Controller [directory]
      • Controller CS files
    • Models [directory]
      • Model CS files
    • Views [directory]
      • View CS files
    • Global.asax
    • Web.config






Friday, April 8, 2011

SQL SERVER – Fix : Management Studio Error : Saving Changes in not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created

Once the table is created open the table in SSMS by clicking on the table name and selecting “Design.” Try to include another column to the existing table and click on save (CTRL+S). It will prevent it from saving and will emit the following error in popup.
Saving Changes in not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created
 I like how SSMS takes stance of displaying warning message and stops user from going further to do operation, thereby preventing hanging of SSMS. However, this feature can cause inconvenience in a situation when one is required to save table using SSMS. If such situation arises, then this feature can be turned off by going to Menu >> Tools >> Options >> Designers >> Uncheck “Prevent Saving changes that require table re-creation”.


This restriction only applies to operation attempted using only SSMS. If modification of tables are attempted using T-SQL in Query Editor, it will work just fine!

ASP .Net Page Life Cycle

1. OnInit (Init) Initializes each child control of the current
2. LoadControlState: Loads the ControlState of the control. To use this method, the control must call the Page.RegisterRequiresControlState method in the OnInit method of the control.
3. LoadViewState: Loads the ViewState of the control.
4. LoadPostData: Is defined on interface IPostBackDataHandler. Controls that implement this interface use this method to retrieve the incoming form data and update the control’s properties accordingly.
5. Load (OnLoad): Allows actions that are common to every request to be placed here. Note that the control is stable at this time; it has been initialized and its state has been reconstructed.
6. RaisePostDataChangedEvent: Is defined on the interface IPostBackData-Handler. Controls that implement this interface use this event to raise change events in response to the Postback data changing between the current Postback and the previous Postback. For example, if a TextBox has a TextChanged event and AutoPostback is turned off, clicking a button causes the Text-Changed event to execute in this stage before handling the click event of the button, which is raised in the next stage.
7. RaisePostbackEvent: Handles the client-side event that caused the Postback to occur
8. PreRender (OnPreRender): Allows last-minute changes to the control. This event takes place after all regular Post-back events have taken place. This event takes place before saving ViewState, so any changes made here are saved.
9. SaveControlState: Saves the current control state to ViewState. After this stage, any changes to the control state are lost. To use this method, the control must call the Page.RegisterRequiresControlState method in the OnInit method of the control.
10. SaveViewState: Saves the current data state of the control to ViewState. After this stage, any changes to the control data are lost.
11. Render: Generates the client-side HTML, Dynamic Hypertext Markup Language (DHTML), and script that are necessary to properly display this control at the browser. In this stage, any changes to the control are not persisted into ViewState.
12. Dispose: Accepts cleanup code. Releases any unman-aged resources in this stage. Unmanaged resources are resources that are not handled by the .NET common language runtime, such as file handles and database connections.
13. UnLoad

Application State in ASP.NET

Application state is used to store data on the application machine. It works as a global variable in other programming languages. Application variable is an object that is shared by the multiple sessions. We can use application variable within page, HttpHandler and Global.asax.

When request a page from client machine, an instance will create at application machine by the help of HttpApplicationState class. Entire application will have only one instance which is provided by HttpContext property named Application.

How to create Application state?

It's very easy to create application state in the ASP.NET application. I am going to take you to write simple application state program now.

Example 1:  In the Global.asax page

void Application_Start(object sender, EventArgs e)

    {

        // Code that runs on application startup

        Application["LoginID"] = "annathurai";

        Application["DomainName"] = "www.annathurai.com";

    }

Example 2:  Inside the .aspx page

protected void Page_Load(object sender, EventArgs e)

    {

// Code that runs on page load

        Application["LoginID"] = "annathurai";

        Application["DomainName"] = "www.annathurai.com";

    }

How to retrieve application state?

It's very easy to retrieve application state in the ASP.NET application. I am going to take you to write simple application state program now.

string loginID=string.Empty;

loginID = Application["LoginID"].ToString();

string loginID = string.Empty;

loginID = Application.GetKey(0);

We can retrieve all application variable on the currently running application's keys by using HttpApplicationState class.

HttpApplicationState appState = null;

appState = Application.Contents;



String[] StateVars = new String[appState.Count];

StateVars = appState.AllKeys;

How to remove application variable?

We have three methods to remove application variable from the ASP.NET application.



  Application.Remove("LoginID");

        Application.RemoveAt(0);

        Application.RemoveAll();

How to implement Synchronization in application state?

We can avoid deadlock occurrence while we updating application variable by multiple users with help of Lock() and UnLock().

        Application.Lock();
        Application["LoginID"] = "annathurai";
        Application["Domain"] = "www.annathurai.com";
        Application.UnLock();

Advantages of application state:

  •           Application object memory relased when we removed.
  •           Multi user can able to access application variable.
  •           To avoid deadlock or conflict we should use Lock and Unlock when we use write or update in the application object.
  •           Other application can't access this application values.

Disadvantages of application state:
  •           Application variable will exists until exit our application.
  •           If we do not have Lock() and Unlock, deadlock will occur.
  •           Its gloable variable so anyone can access within this application.