Skip to main content

Posts

Function in Razor view (@helper in razor)

We can create function in cshtml by using @helper syntax syntax: @helper <FunctionName>(paramtype param1) { //your custom logic } Here the function is same as the one we write in class file except  "@helper" . This function can be invoked from any where in the view simply like this @FunctionName(param1); @helper syntax enables in code reusability scenario : Following code implements recursive function using @helper in view @helper Recurson(IEnumerable<Menu> nodes, int? parentId) {     if (nodes.Any(n => n.ParentId == parentId))     {         <ul>             @foreach (var node in nodes.Where(n => n.ParentId == parentId))             {                 <li>                     @node.Name                 ...

work out with SignalR

In this post i will be talking how we can use signalR for real time web application with a demo chat application. If you are reading this post and don't know about installing the required files please have a look at my previous post. http://mesushil.blogspot.com/2013/04/introducing-signalr.html here i am modifying the default asp.net template about.aspx page for the demo. Firstly include the script in the .aspx page . the second js i have included here is the js downloaded by the nuget. the third file is generated at run time including the hubs declared in the server. check the browser to ensure these files are loaded in the browser. the image above is the part of hubs.js generated dynamically. now lets create hub in the server.for this lets include a class file to the solution. To create the hubs in server add the namespace as the first two lines above. hubName in line 9 is what we will be referring in client side js to communicate with the server. and t...

Introducing SignalR

Introduction: Asp.net signalR is an open source library for asp.net developers.it is used to implement real time functionality in web application. requirements: signalR is not included in visual studio so far(vs 10 and vs 12) by default.It can be implemented in .net framework 4.0 and higher. so you need vs 2010 or vs 2012 to start taking the advantage of signalR. I will guide you trough the installation of signalR for your project . Lets get ready with the visual studio 2010 or 2012. I am going to use visual studio 2012 here. Firstly open up a new project. now open a Package Manager Console. if you didn't find it click View and go over to other window you find it there or go to Tools>Library Package Manager Console >Package Manager Console  make a command in console :Install-Package Microsoft.AspNet.signalR  Scroll down the generated text in console few files are downloaded which contains the asp.net server side  signaR and client side signalR ...

getting the list of class from dll in asp.net c# using Reflection

Reflection provides object(of type Type) that describe assemblies modules and types. so we can use  reflection to get the info about the assemblies i.e we can access  all types of objects in the dll.here I am going to demonstrate the use of Type and LoadFile to to get the name of the classes in the dll. demo code : using System; using System.Collections; using System.Reflection; namespace Zeewon.Tests {     public class GetClassInDll     {         public GetClassInDll()         {         }         //string dllname is the path of the dll //as LoadFile takes the absolute path the absolute path should be provided as parameter         public ArrayList GetClassName(string dllName)         {         ...

Joins in sql

Join To return  a result set, combined from multiple tables joins are implemented . lets take the  two tables below for study.  Inner Join when inner join is applied it selects the rows which matches the join fields in both the table (simply it is called a join). query:                select s.StudentId,s.TeacherId,s.Name as student_name,t.Name as teacher_name                       from Student s   inner join Teacher t                       on s.TeacherId=t.TeacherId  result: Outer Join Left outer join Returns all rows from the left table (that means the table specified first in select statement) and only the matching rows from the next table(matching refers to the join fields being equal) query :       ...

Simple example for Pivot in SQL

In this Post I am going to explain pivot with a simple example. In  general Pivot means a point on which a part rotates. In same thing applies,Here the Pivoting means making the column change to a row . With out further defining I would like to demonstrate it with a simple example. Figure above shows a table with two columns .Now I would like to change the columns to rows  I have the procedure above  : this is the result generated by above procedure . Explaining the procedure: The first line selects the data as the defined header after being pivoted .next selects the columns key and value  from the pivot table while the statement after pivot makes the value column as header and the key as data under the column. I hope this Post would help the beginners who are new to the SQL and want to learn the basic syntax of pivot. Thank you for reading . Any suggestions regarding the post are welcome .

A start with NerdDinner

Few days and still going on. just a new learner , enthusiast and with the hope of doing better . I am going through this blog just to put a little art of writing in what i have done in learning mvc. Going through it for about three days , i have gathered a little courage in what i am doing right now. After a little knowledge in model view and control while going through NerdDinner , I came up to create a view for a controller then a real work out was required .Right now i am going to stop my embarrassing writing and and explain what i went through during the last day in those three days. Creating a view in mvc gives us the option to create a partial view and a strongly typed view . I haven't gone through the partial view so i would just skip to the strongly typed view . While adding the strongly typed view we get the list of class that we have in the Model. selecting one of the class generates the view that is required to handle the instance field that we have created in the D...