Monday, February 27, 2012

New Features in ASP.NET MVC 4

Here i will given what are the new featured are introduces in ASP.NET MVC 4 beta version.
It includes ASP.NET web API,A new framework to creating HTTP services.By using this framework we can reach clients including browsers and mobile devices. ASP.NET Web API is also an ideal platform for building Restful services.

The ASP.NET Web API includes following features:

1.Modern HTTP programming model
2.Full support for routes
3.Content negotiation
4.Model binding and validation
6.Improved testability of HTTP details
7.Improved Inversion of Control (IoC) via Dependency Resolver
8.Code-based configuration
10.Introduced New HTML5 project template and mobile templates
download ASP.NET MVC 4

Friday, February 24, 2012

Microsoft JScript runtime error: 'jQuery' is undefined

When i am working with jquery in application ,Suddenly i stuck  with the following error.i:e "Microsoft JScript run time error: 'jQuery' is undefined".This is the common error will arise when working with Jquery.

The main reason for this is the jQuery library could not be loaden when we run the application because of made a wrong reference or forgot the reference to the jQuery library at all.
Then i will including jquery-1.4.4.js to my application.The my issue has resolved after add this jquery library reference
<script src="~/Scripts/jquery-1.4.4.js" type="text/javascript">

Thursday, February 23, 2012

Granting Privileges to a role in sql server

To grant privileges to a role use the same syntax as granting privileges to a user except that in the place of user name specify the role name.Here i will shown a example to grant various permissions on the tables orders,sales and customers to the role myrole
Grant select,Insert,Update(name,job) on orders to myrole
Grant select,Insert,Update on sales to myrole
Grant select,Insert,Update on customers to myrole
Adding a member to the role:To add a member to the role use the procedure sp_addrolemember
sp_addrolemember 'rolename','username'
if you want to delete the role myrole then the below syntax will be used
sp_droprole 'myrole'

Tuesday, February 21, 2012

Features of Dotnet Nuke 6.0

DotNetNuke is an open source Web Content Management System (CMS) for Microsoft .NET. DotNetNuke (DNN) Enterprise Edition 6.0 has endless possibilities for developing an resourceful website and business applications .

Features of DotNetNuke Enterprise 6.0 are :-

1) New Look
2) Fully Integrated
3) Microsoft SharePoint Connector
4) DNN eCommerce
5) DNN in the Cloud
6) DNN Learns a New Language

For more details description about DNN 6.0 Feautres

Monday, February 20, 2012

Http Handler in

Basically all of you know what does the http handler in .We can simply say about HTTP handler is get the input from the the HTTP packet,do some tasks and prepares a return HTTP packet.Here i will explain the brief explanation about handler working in

A Http handler component is an instance of a class that implements the IHttpHandler interface.This is base of the run time architecture.
public interface IHttpHandler
public void ProcessRequest(HttpContext context);
public bool IsReusable;

The Process Request takes the context as the input and ensure that the request is serviced.In the case of synchronous handlers,when Process Request returns,the output is ready to go the client.For this some methods are work in IHttpAsyncHandler interface

Sunday, February 19, 2012

Basics of wcf

WCF stands for Windows communication foundation.SOAP is an attribute it is used on web method.It is recommended to work with WCF 3.0,3.5,3.5sp1,and 4.0 .Data with WCF is also recommended using LINQ to SQL and entity framework.WCF is completely configuration based and many tasks in WCCF can be done with configuration.WCF even supports consuming classes pragmatically writing code to perform it's actions but nobody uses WCF with code because configuration based is a big advantage.

WCF supports attribute based programming for every behaviour of server and it has lot of attributes along with properties to fulfill the distributed application environment.
[attribute] attributes are classes
WCF unified model is prepared with simple ABC model
Now i will show you how we are communicating in WCF.The Binding concept is used to communicate in WCF.TCP,SOAP,Meta data binding these are computer terms.WCF generate WSDL based on Contract.Contact will come interface what will gives that's it
A+B+C=End point in WCF
you can have multiple ENDPOINTS .To serve the same Contracts different types of clients.
A network address where the End point resides.

Binding:Specifies how the End point communicate with the world
-Secirity options(SSL,message security)

BasicHttpBinding ,NetTcpBinding ..etc
Contract:Specifies what the endpoint communicator
define the things like
-message exchange patterns
-service operations
-Behaviour(exchange meta data-Data,Authorisation-etc)

Wednesday, February 15, 2012

how to Implement wcf service

Vs 2010 provides different templates for develop WCF services .One it provides in file--> new website-->WCF service using which we can design develop WCF service in simplified manner by default this template will create One .SVC file fallowed by two .cs files.Most importantly End points for this new service are also created in web.config file.We can add more services using add new item WCF service template for every service that we create automatically.End points along with other configuration settings are written system.Service model is the tag where all these End points are defined.we can directly add more end points otherwise use wcf configuration editor utility to modify or add more points.

Here i will shown how to create a simple web service .For this we have to fallow the below steps.

start wcf service and add two more services called Products and category.These two are services we will use to provide categories and Products information.

The back end layer is performed using LINQ SQL and entity framework add entity framework classes using add new item from App code and choose entity data model.EDM is very complex to create for our application but with EDM designer provided with VS to maximum extend we can simplify the creation of entities.

One EDM class are lINQ to SQL classes are prepared.Then we can provide operation contracts fallowed by implementation in our service and it's class go to products and add the following operation contract

[operation contract]
void Dowork()
[operation contract]
list GetProducts();
[operation contract]
products GetProducts(int product id);
[operation contract]
list GetProductsIn category(int cat id);

Now go to implementation class of this contract i:e product class.Implementation of each method like this

public listGetProducts()
{//linq to entities
Eshopmodel.Eshopentities obj=new Eshopmodel.EshopEntities();

var x=from n in obj.Products select n;
return x.Tolist();
public Eshopmodel.Products GetProducts(int productid)
Eshopmodel.EshopEntities obj=new Eshopmodel.EshopEntities();
var x=(from n in obj.products where n.productid==productid select n).First or default();
return x;
public Eshopmodel.Products GetProductsInCategory(int catid)
Eshopmodel.EshopEntities obj=new Eshopmodel.EshopEntities();
var x=(from n in obj.products where n.productid==catid select n).First or default();
return x.Tilist();

Tuesday, February 14, 2012

Convert string array to list in c#

Title:How to Convert string array to generic list in using

As in previous articles we have seen the data type conversions.Now i would like to give an example on how to convert the string array to List .To elaborate the example i have used a string "strs".Then it will split and store into array "StrArray".Finally the array is convert to list using below peace code and assign to list details List.
string strs = "1,1,3,4";
List detailsList;
string[] StrArray = strs.Split(',');
int[] intArray = Array.ConvertAll(strArray, new Converter(Convert.ToInt32));
detailsList = intArray.ToList();
Dim strs As String = "1,1,3,4"
Dim detailsList As List
Dim StrArray__1 As String() = strs.Split(","C)
Dim intArray As Integer() = Array.ConvertAll(strArray, New Converter(Convert.ToInt32))
detailsList = intArray.ToList()

Monday, February 13, 2012

New features in 4.5

The latest version for 4.5 has been released September 2011.It includes a lot of great features in the ASP.NET .It has one of the latest HTML version which is  HTML5 with Updates.It will ignore the browser issues for design of applications

New in 4.5:
1.ASP.NET Core Run time and Framework
2.Asynchronously Reading and Writing HTTP Requests and Responses.
3.Improvements to Http Request handling
4.Asynchronously flushing a response
5.Support for await and Task-Based Asynchronous Modules and Handlers
6.Asynchronous HTTP modules
7.Asynchronous HTTP handlers
8.New ASP.NET Request Validation Features
9.Filtering by values from a control
10.HTML Encoded Data-Binding Expressions
11.Unobtrusive Validation
12.HTML5 Updates

To more description about New Features For more
DownLoad VS2011

Saturday, February 11, 2012

session and application in is a collection of objects.In that application is one.In all objects "application" is one object.In order to serve any resource from a web app first application should be loaded  and then resource will be serve.
When first user makes a request for any resource in the app'n then creates an app domain and loads the project inside it.When all sessions at server are lost and allocated application resources are also destroyed then run time can remove the appn.

when  a new user makes a request  session is used to uniquely identify uses in a a web app.session is created  whenever a new user  makes a request .Every session is Identified with a unique id called session Id.This id travels between requests and response
Every session create with a timeout 20 min by default
if user doesn't respond with in 20 minits then sever is going to all cleanup the session.alter this if user makes a request creates a new session and serves data in the session will be last
Session can also be closed pragmatically using Abandon() method of it

Developer can use application that represents an application and session which represents the sub process or session only in 2 ways
1.In the form variables for state management
2.In the form of events preforming actions and during their involved tasks.
Both variables and events are not mandatory for any web app but every project needs application and session level takes which are fulfilled only using events and also secured,higher level state provided with application and session variables only
public void application_Onstart()
public void session_Onstart()
Application["user"]=(int)Applciation ["Useronline"]+1;
public void session_OnEnd()
Application["useronline"]=(int)Applciation ["Useronline"]-1;
//under page load
protected void button _click(object sender,Event args e)
lblapp.Text="visitorno:"+Applcation["users"].To string();
lbl.Text="onlineno:"+Applcation["usersonline"].To string();
//In markup language
go  to web.config
<session state timeout="1"></session state>

we can change the time of half session pragmatically using  session.Timeout=n' and also in web.config markup using  session.timeout=1
By default session are also maintained internally using cookies which means we are dependent on browser again and our application may not run based on browser settings.Again session i can be managed cookies less.Cookie less means we are dependent on URI and using session state tag we can specify this settings

Friday, February 10, 2012

Customising Authentication Security using configuaration Tags in web.config in

Forms Authentication mode of Provided Ticket handling and also different properties to deal with security management using authentication tab of web.config.We can provide same settings to change the default behaviour of application.Here will given some options to for

customising security in application:
1.We can change the redirect login page ans ask FAM(form authentication mode) to show different page for authentication all these settings are provided using forms tag of authentication
<authentication mode="Forms">
<forms loginurl="Login.aspx">
<user name="test" password="test">

we have use the FormsAuthentication.Authenticate method to authenticate to users in codebehind
code behind:

string user=this.txtUserName.Text;
string pws=this.txtPassword.Text
if (FormsAuthentication.Authenticate(user,pwd)
FormsAuthentication.SetAuthCookie(user, false);
FormsAuthentication.RedirectFromLoginPage(user, false);
Response.Write("try again.");

2.When user directly visits login.aspx there will be no written URL after successful login.In that case by default redirects the user to default.aspx of rule.If we want to customise this default URL of forms tag can be use
<authentication mode="Forms">
<forms loginurl="~/admin/adduser.aspx">
</authentication> ticket name to create authentication ticket in our program we provide a value internally.This value is stored with a name called ".aspxauth".It is highly recommended to change this default name we can change it using name attribute
By default forms authentication module Creator Identity using cookies of HTTP.but cookies are dependent on browser .According to browser instructions cookies behave which is a big problem or effect for our authentication ticket.To over come this universal problem has provided an alternate use URI option cookieless="useURI" with this we are independent of browser and cookies Auto direct means use cookies if supported otherwise useURI use device profile means get the cookie less setting from profile section of web.config
5.Protection=All,encryption,none,validation default is all recommended is also all This protection attribute is for authentication ticket protection all means encryption+validation which is high level of security.we can go to low levels like only encryption only validation also with none no protection at all.In a simple text ticket is created.

6.Request="true" default is false.If set to true browser should make request for every authentication related task using https instead of http(ssl enabled)
7.EnablecrossAppRedirects="true" or "false" .default is false with this option we can use authentication ticket to othersites who fallow forms ans also other site tickets in our site by setting it to true.highly not recommended because every browser doesn't support this

Wednesday, February 8, 2012

how to Passing a server side variable into javascript

Recently I have seen a server side code which is used to pass the server side value to javascript.So whenever we will transfer the server side value to Javascript we don't need to write server side .For this here i will show a simple way to pass the variable to javascript from server side
<input id="hidCtrl" type="hidden"  runat="server" value='<%# ServerVaribaleValue %>'/>
Here the server side value which is"ServerVaribaleValue" is assigned as a hidden field value.The below javascript will get the value of hidden field
<script language="javascript">
function onclick(){

Tuesday, February 7, 2012

Return values from a sql server stored procedure

If you want to return a value from a procedure ,the parameter which return the value has to be declared using the output class
note:A procedure can return one or n values at a time
procedure test(@x int,@y int output)
                |         |
              input     output
              Parameter  Parameter
Create procedure process(@x int,@y int,@z int output)
SET @z:@x+@y
//calling the above procedure
Declare @a int
EXEC Process 100,50,@A output
print @A
While returning a value from a procedure you don't require to use any return statement .If you assign the values to the output parameter ,procedure only will take the responsibility of returning the values

Procedure with multiple output parameters:
Here i will show a procedure which can be used for inserting the id,name,sales and city into orders table
Create procedure insert_orders(@id int,@name varchar(50),@sales money,@city varchar(50) 
Insert into orders(Id,name,sales,city)values(@id ,@name,@sales,@city)
*calling above procedure
EXEC insert_orders 1,'aaa',3000,US

Monday, February 6, 2012

how to create breadcrumb in Ektron cms

Breadcrumbs are display at top of a web page ,which is provide the path for where we came from previously.breadcrumbs are set at the folder level, so we have to give them only for the main content block in the folder, Then breadcrumbs will automatically be set for the remaining of that folder’s content.
Ektron.Cms.API.Content.Content contentApi = new Ektron.Cms.API.Content.Content();
ContentData content = contentApi.GetContent(PageHost1.PageID);

if (content != null)
long fid=content.FolderId;
Ektron.Cms.API.Folder folderApi = new Ektron.Cms.API.Folder();
FolderData folder = folderApi.GetFolder(fid);
if (folder == null)
Ektron.Cms.Common.SitemapPath[] mapPath = folder.SitemapPath;
if (mapPath == null)
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mapPath.Length; i++)
if (mapPath[i] == null)
if (sb.Length != 0)
sb.Append(" > ");
if (i < mapPath.Length - 1)
sb.AppendFormat("{1}",!String.IsNullOrEmpty(mapPath[i].Url) ? "/" + mapPath[i].Url : "/", mapPath[i].Title);
BreadCrumb.Text = sb.ToString();

Sunday, February 5, 2012

Export excel data to sql server Data base in

Now a days we have an mandatory requirements like export data to excel in and excel to database etc.Here i will show how to export the data from excel to Database in the below example i have taken one excel sheet"testexcel.xls" with data.when ever work with excel data base we have to add one namespace i;e, System.Data.OleDb;.
DataTable dt = new DataTable(); 
OleDbConnection oledbcn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ Server.MapPath("~/testexcel.xls").ToString() + ";
Extended Properties=Excel 8.0;");  
//sheet name 
string SheetName="orders";oledbcn.Open(); 
OleDbCommand cmd = new OleDbCommand(@"SELECT * FROM [" + SheetName + "$]", oledbcn);  
OleDbDataAdapter oledbad = new OleDbDataAdapter();  
oledbda.SelectCommand = cmd;
//if we have a large amount of data we have to use for lop to isert the data   
StringBuilder Str =new StringBuilder();
foreach (DataRow dr in dt.Rows)
 Str.Append("INSERT INTO Orders VALUES(" + dr["ID"].ToString() + ",'" + 

dr["Name"].ToString() + "')");

Saturday, February 4, 2012

difference between class and structure

1)It is a referece type
2)Memory is allocated on managed Heap
3)They are not faster in access
4)New is mandatory for creating an object of a class
5)default constructor is option in under a class
6)It can be declared with variables and assigned with values while declaration
7)class provides both implementation as well as interface inheritance
The clssses for implementaion of complex business logics

1)It is a value type
2)Memory is allocated on stack
3)They provide faster in access
4)It is optional while creating an object of a class
5)default constructor is mandatory which will be idebtified by compiler
6)It can be always declared with variables but can not be initiallised while declaration
7)it provides only interface inheritance
The strucutres for implementaion of small business logics

Thursday, February 2, 2012

Programmatically get the taxonomy in ektron cms

Taxonomy is used to specify the hierarchical path in website.When ever we create a taxonomy for website we need to follow the menu structure in work area.Here i will show how to create a Bread crumb using Taxonomy.Before get the bread crumb path we have to know about condition which are get the child and parent items in taxonomy,Which API code have to use to get the data of Taxonomy.The Taxonomy API is used to get the taxonomy API.Here i have taken a bread crumb server control and assigned the path of pages.
The page is getting by using the Page Host when the page is loaded,then the content id is get by using page Id.When ever page load The taxonomy data does get all the categories. For this we need to loop through it to get the all.The parentId > 0 is t get the parent item s of current page in taxonomy
Code behind:
using System;
using Ektron.Cms;
using System.Xml;
using System.Text;
using System.Collections.Generic;
using Ektron.Cms.Common;
using Ektron.Cms;
using System.Web.UI.WebControls;
public partial class SubPageLevel_1 : System.Web.UI.MasterPage
protected void Page_Load(object sender, EventArgs e)
Ektron.Cms.API.Content.Content contentApi = new Ektron.Cms.API.Content.Content();
ContentData content = contentApi.GetContent(PageHost1.PageID);
if (content != null)
long cid = content.Id;
if (cid > 0)
Ektron.Cms.API.Content.Taxonomy TaxAPI = new Ektron.Cms.API.Content.Taxonomy();
Ektron.Cms.TaxonomyBaseData[] TaxData = TaxAPI.ReadAllAssignedCategory(cid);
foreach (Ektron.Cms.TaxonomyBaseData t in TaxData)
if (!Page.IsPostBack)
long taxid = t.TaxonomyId;
Ektron.Cms.Controls.Directory taxControl = new Ektron.Cms.Controls.Directory();
taxControl.TaxonomyId = taxid;
taxControl.Page = this.Page;
Ektron.Cms.TaxonomyData taxData = new Ektron.Cms.TaxonomyData();
taxData = taxControl.TaxonomyTreeData;
long parentId = taxData.TaxonomyParentId;
TaxonomyData tmpTaxData = default(TaxonomyData);
Ektron.Cms.Controls.Directory tmpTaxControl = default(Ektron.Cms.Controls.Directory);
string breadCrumb = taxData.TaxonomyName;
string link = null;
while (parentId > 0)
tmpTaxData = new TaxonomyData();
tmpTaxControl = new Ektron.Cms.Controls.Directory();
tmpTaxControl.TaxonomyId = parentId;
tmpTaxControl.Page = this.Page;
tmpTaxData = tmpTaxControl.TaxonomyTreeData;
link = "" + Server.HtmlDecode(tmpTaxData.TaxonomyName) + " > ";
breadCrumb = breadCrumb.Insert(0, link);
parentId = tmpTaxData.TaxonomyParentId;
tmpTaxControl = null;
taxoBreadCrumb.Text = breadCrumb;

Wednesday, February 1, 2012

how to use the abstract class in

The class under which we define the abstract methods is an abstract class.Abstract class has to be declared using "abstract" keyword.
abstract class example
public abstract void test();
An abstract class can contain both abstract and non abstract methods in it.Each and every abstract method which was declared under the abstract class should be given implementation with in the child class or child cannot utilize non abstract methods of the parent.An abstract class is not usable for it self because the object of an abstract class can't be created using "new" operator.It can be utilized only by the child class after giving the implementation for abstract methods of parent.If the child class doesn't provide the implementation for the abstract methods in its parent child also becomes abstract.
abstract class parent
public int add(int a,int b)
return a+b;
public int sud(int a,int b)
return a-b;
public abstract int mul(int a,int b);
public abstract int div(int a,int b);
//Add one more class child.cs

class child:parent
public override int mul(int a,int b)
return a/b;
public void test()
Console.Writeline("child method");
static void menu()
child c=new child();
The object of an abstract can be created by assigning the object of it's class to it's variable,using this object every method declared and implemented under the abstract class can be called.Here the following code under the main methods of child class
Note:In derived class i have override the mul() method
parent p=new child();