Tuesday, 16 December 2014

SharePoint 2013 Visual webpart ".ascx.g.cs" file is not updating.

I created a SharePoint 2013 visual webpart using VS2013 and I did some modification in the namespace and class name for naming convention.  After this my ".ascx.g.cs" is not updating.  Then I cant add new controls in the webpart.

I found the reason is below entries are missing in the .proj file.  After adding the below entries everything working fine.

Entry 1

Before:
    <Compile Include="Webparts\testWebPart\testWebPart.ascx.g.cs" />

After :
    <Compile Include="Webparts\testWebPart\testWebPart.ascx.g.cs" >
       <AutoGen>True</AutoGen>
       <DesignTime>True</DesignTime>
       <DependentUpon>test.ascx</DependentUpon>
    </Compile>

Entry 2

Before: 
  <Content Include="Webparts\SiteMapWebpart\test.ascx/>

After

      <Content Include="Webparts\SiteMapWebpart\test.ascx">
      <Generator>SharePointWebPartCodeGenerator</Generator>
      <LastGenOutput>test.ascx.g.cs</LastGenOutput>
    </Content>

Happy Coding :) - Sugu
 

Monday, 23 September 2013


ஏற்ப்போ மறுப்போ வரட்டும்....  இப் போதைக்கு நன்றி !!!!

Tuesday, 18 October 2011

Data first approach in MVC3


Data first approach in MVC3
Project First Appearence - Database DB First Approach ASP.NET 4 MVC3
BlogContent DataTable Data
Taxonomy Data
ContentType Table Data
Existing Database table relationships schema Database DB First approach



Creating ADO.NET ENTITY Data Model From a Existing Database Database First Approch


Generate Entity Data Model From Existing Database DB Database DB First approach 

Creating ConnectionString from Exiting Database - Database First approach


Entity Data Model Edmx file view


 right click on the white surface in the entity data model of Blog Database.

DBContext Generate From Entity Data Model

Creating Repository Model and Database Table Class from the Entity Data Model, Click on 'ok' twice

After Creating RepositoryModel and DBContext from Wizard


Controller Wizard to Create V-View, C- Controller
V-View and C- Controller has been created with Read,WriteDeleteDetails View ability

Created a Link for the Blog Content Controller

Preview of the Project

Can't find ADO.NetDbContext Generatior

        I was tried my first exercise in MVC 3 to connect with database using entity framework by following the video in the url http://msdn.microsoft.com/en-us/data/gg702905.
   
        But I cant find the  ADO.Net DbContext Generator in the add new window.  I was find out the solution to add the http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=18504 to the visual studio now it is working fine...

        Happy Coding....

Wednesday, 5 October 2011

Template function and Template class in C++

        Template function is a generic type function which is supported to all data types.  It is used to avoid the repetition.

For Example:
         We want to write function to find the maximum number from given two numbers.  The given number may be integer,long or any type.  By using the classic method we must write separate function for integer and long.

int findMax(int a,int b)
{
   int result=(a>b)?a:b;
   return(result);
}

log findMax(long a,long b)
{
   long result=(a>b)}a:b;
   return result;
  }

int main()
{
    int a=10,b=20;
    long x=8.7,y=9.08;
    cout<<findMax(a,b);
    cout<<findMax(x,y);
    return 1;
 }

      We have two functions in the above code both are same except the data type to avoid this repetition we will using the Template function.

template <class myType>
myTytpe findMax(myType a,myType b)
{
   myType result=(a>b)?a:b;
   return result;
}

int main()
{
    int a=10,b=20;
    long x=8.7,y=9.08;
    cout<<findMax(a,b);
    cout<<findMax(x,y);
    return 1;
 }

Template Class 
       Template class is an generalized class. Which is the extension of the template function we can use the generic data type in the whole class i.e more than one function and declare the properties with the template data type.

Example


      I want to create a stack for the integer and string in the classic approach a separate class for integer and separate class for string.  Except the data type remaining all are same.

Like following program


       class IntegerStack 
       {
        public:
         IntegerStack() { top = -1; }
        void push(int i)
          { stack[++top] = i; }
        int pop()
          { return stack[top--]; }
        private:
          int top;
          int stack[100];
       };

       class StringStack {
public:
StringStack() { top = -1; }
void push(string i)
           { stack[++top] = i; }
          string pop()
          { return stack[top--]; }
       private:
          int top;
          string stack[100];
       };

     we will template class instead of this classic approach

template <class T>
class Stack {
     public:
       Stack();
       void push(T i);
       T pop();
     private:
      int top;
      T st[100];
     };

    template <class T>
     Stack<T>::Stack()
     {
      top = -1;
     }

   template <class T>
   void Stack<T>::push(T i)
    {
     st[++top] = i;
    }

   template <class T>
   T Stack<T>::pop()
    {
     return st[top--];
    }

   int main()
{
  Stack<int> integer;
  Stack<string> string;
  integer.push(10);
  string.push("sugunthan");
}




Tuesday, 4 October 2011

Extension Method in C#

Extension method is an very useful method to the developer.  It will extend the methods of an existing class.  That is we are regularly using the string methods like
 1.ToLower
 2.Toupper

   string s="sugunthan";
   string upper=s.ToUpper();

Like this way I want to reverse my string by using an method

Using older method


class Program
    {
        static void Main(string[] args)
        {


            string s = "sugunthan";

            stringmethod sm = new stringmethod();

            string reverse = sm.Reverse(s);
            Console.WriteLine(reverse);

        }
    }

    class stringmethod
    {
        public string Reverse(string source)
        {
            string n = string.Empty;
            int size = source.Length;
            size = size - 1;
            for (int i = size; i >= 0; i--)
                n = n + source[i];
            return n;

        }
    }



     In this classic approach we must create an object for the class and call the function by using that class.
Instead this old way we will using the extension method
The advantages are
          1.  Use as like other build in string methods i.e with intelligence
          2.  Able use with the constant like "sugunthan".Reverse();
          3.  Dont bother about the parameter type.
Example

using MyExtensionMethods;


namespace extension_methods
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "sugunthan";
            string reverse = s.Reverse();
            Console.WriteLine(reverse);
            Console.WriteLine("extension method".Reverse());
        }
    }
}



namespace MyExtensionMethods
{
    public static class MyExtension
    {
        public static string Reverse(this string source)
        {
            string n=string.Empty;
            int size = source.Length;
            size = size - 1;
            for (int i = size; i >= 0; i--)
                n = n + source[i];
            return n;

        }
    }
}