Monday, July 17, 2017

How to Open Zerodha Demat Account





How to open Zerodha demat account

Click the below link and submit your details -




https://zerodha.com/open-account?c=ZW9465

Monday, February 1, 2016

Convert String to Integer in IBM BPM



Convert String to Integer in IBM BPM
-- OR --
IBM BPM string to integer
-- OR --
IBM BPM convert string to integer
 

 

tw.local.pIntegerVariable = Number(tw.local.pStringVariable);

  where tw.local.pStringVariable is String Type and tw.local.pIntegerVariable is Integer Type

Friday, September 14, 2012

Dot Net Interview Questions

Dear Readers,

I am sharing the some interview questions, that is being asked in many companies. I hope it will be very helpful for all of you.


OOPs
  1. Cohesion and Coupling
  2. Virtual funcation table in OOPs


C#
  1. array.sort
  2. can we have property and indexer in an interface
  3. can we create indexer for a class which have property
  4. copy and clone of array and and data table and dataset
  5. Difference between static class and singlton class
  6. difference between an abstract method and virtual method
  7. Collections in .Net
  8. difference between Copy and Clone Method
  9. Difference between Dispose and Finalize
  10. Difference Between Int32
  11. Difference Between Readonly and Constant
  12. Difference between struct and Class
  13. Difference between type constructor and instance constructor
  14. Difference between out and ref in c#
  15. Difference between CLS and CTS
  16. Difference between Metadata and Menifest
  17. What is Serialization?
  18. How Garbage Collector works?
  19. How GC remove stack memory?    http://www.codeproject.com/Articles/76153/Six-important-NET-concepts-Stack-heap-value-types
  20. What is Generics?
  21. Why doesnt C# support multiple inheritance



ASP.Net
  1. How to get value of HTML Control at server side.
  2. Form authentication
  3. how to call Web Service from javascript or jquery
  4. custom paging in grid view
  5. autoeventwireup in asp.net
  6. session.abondon and session.end
  7. difference between application variable and static variable
  8. 2 page in registration page, how to get page 1 values:- Hint:- Page.PreviousPage Property
  9. In a aspx page 10 text box has required field validate, having two button. on click of button1 call validate of only 5 text box and same for other button.
  10. using keyword.
  11. server variable in asp.net
  12. how to call user control from another user contorl.
  13. how to call a javascript function form aspx.cs file
  14. how to call a cs function for aspx page
  15. how to call a web service from javascript
  16. exception handling in application level?? Answer Hint:- In global.asx file.
  17. How do u handle Exceptions in  your application.
  18. Difference between custome control and user control.
  19. Difference between application variable and cache object
  20. Difference between application variable and static variable
  21. Difference between Session.Abandon() and Session.Clear() in ASP.Net
  22. Why custome control is in DLL form.
  23. Tell me something HttpPipeline/Request Life cycle.
  24. Give name of any asp.net http module
  25. Give name of any asp.net http handler
  26. Difference between HTTP Module and HTTP Handler
  27. Cookieless Session in ASP




SQL Server
  1. difference between nvarchar, varchar, char in sql
  2. difeerence between cast and convert in sql
  3. how to pass a collection in stored procedure
  4. Highest Salary
  5. Get sum of row in sql
  6. wothout using distinct keyword.
  7. you are having 2 tables:- you have table one records (1,2,3,4) in table2 (1,2):-write the query for both table and get only record which in not available in table2 dont use sub query. ANswer:- use left outer join and where id of table1 is not equal to table2


WCF
  1. difference between web service and wcf.
  2. security in wcf
  3. Difference between BasicHttpBinding and WsHttpBinding
  4. If you have a WCF Service and there is 10 method inside that. Suppose there are three different client accessing that service. How will you allow client 1 to have access only 2 methods, client 2 can access only 5 methods and client 3 can access all 10 methods. How will you achieve that.


_viewstate
_event target
_event argument
http://forums.asp.net/t/1352215.aspx
http://www.evagoras.com/2011/02/10/how-postback-works-in-asp-net/
http://www.codeproject.com/Articles/12422/How-to-know-which-HTML-object-was-clicked




http://www.velocityreviews.com/forums/t509254-difference-between-refreshing-a-page-postback-and-viewstate.html


http://msdn.microsoft.com/en-us/library/ms972976.aspx
http://stackoverflow.com/questions/2953587/viewstate-vs-postback
http://www.codeproject.com/Articles/31701/ViewState-and-Postback
http://asp.net.bigresource.com/what-is-the-difference-between-postback-data-and-view-state-data-pGktGAJ1J.html
http://aspalliance.com/articleViewer.aspx?aId=135

Friday, June 29, 2012

Save SQL Query Results With Column Names

Save SQL Query Results With Column Names

 

It can be done by going to Tools - Options - Query Results - Sql Server - Results to Grid - Include column headers when copying or saving results. 



Click on Options....
 


 Click on Ok...





 Run your query and then Right click on Result -> then click on “Save Result As…”



 

Now, you can save the output in an excel file with Column name.

Tuesday, May 8, 2012

DataTypes in C#.NET

 DataTypes in C#.NET:-
 
All the data types in .net are available within the namespace System and are as follows.

 Category  Class/Structre Name Data Type in C#.NET  NO. of Bytes   Range
 Integer  System.Byte  Byte  1(Unsigned)  0 to 255
   System.SByte  Sbyte  1(Signed)  -128 to 127
   System.Int16  Short  2(Signed)  -32,768 to 32,767
   System.Uint16  Ushort  2(Unsigned)  0 to 65,535
   System.Int32  Int  4(Signed)  -2,147,483,648 to 2,147,483,647
   System.Uint32  Uint  4(Unsigned)  0 to 4,294,967,295
   System.Int64  Long  8(Signed)  -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
   System.Uint64  Ulong  8(Unsigned)  0 to 18,446,744,073,709,551,615
 Float        
   Single  Float  4  ±1.5e−45 to ±3.4e38 
(Precision:7 digits)
   Double  Double  8  ±5.0e−324 to ±1.7e308
(Precision:15-16 digits)
   Decimal  Decimal  16  (-7.9 x 1028 to 7.9 x 1028) / (100 to 28)
(Precision:28-29 digits)
 Character        
   Char  Char  2  
   String  String  size varies  
 Other        
   DateTime  DateTime  8  
   Boolean  Bool  1  
   Object  Object  size varies  Can store any type of value


Note: Of all the datatypes, string and object are reference types while all other are value types.

Friday, May 4, 2012

Assembly in .Net


An assembly is a fundamental unit of any .NET application. It contains the code that is executed by CLR (common language runtime). I would like to limit the details to what is required to create and use an assembly. For more information about all nitty gritties of an assembly, please refer to MSDN documentation.
However, it is important to know a few details about assemblies before we delve into creating and using it.
  • An assembly contains name, version, types (classes and others) created in it and details about other assemblies it references.
  • An assembly may be either an executable file - .EXE or a dynamic link library - .DLL
The following is the content of an assembly. Each assembly contains first three parts. Fourth part may not be present in all assemblies. It is used primarily for localization - using resources according to the country or region.
  • Assembly Metadata or Manifest
  • Type Metadata
  • MSIL Code
  • Resources
Assembly Metadata or Manifest
This contains information about the assembly. Remember, assemblies in .NET are self-describing. They contain all the information that .NET needs to use them. Assembly metadata contains the following details of an assembly:
  • Assembly name
  • Version number of the assembly, which has four numbers in the format major.minor.revison.build
  • Culture - language assembly supports
  • Strong name - required only for global assemblies
  • List of files in the assembly. An assembly can be made up of multiple files
  • Type reference information - informs which type is in which file of the assembly
  • Information about referenced assemblies - Contains list of other assemblies referenced by this assembly. For each assembly referenced we have assembly name, version, culture and public key (if assembly is a global assembly)
Type metadata
This section of an assembly contains information about all classes, structure etc. created in the assembly.
MSIL Code
MSIL code of the assembly is placed in third part of the assembly. This MSIL is converted to native code by CLR at runtime.
Resource
This section contains messages and pictures used by assembly.
How to create an assembly in C#
The following are the steps to create a private assembly (by default all assemblies are private) using Visual C# 2005 Express Edition.
  1. Select File->New Project
  2. From Templates, select Class Library
  3. Enter name CounterLibrary
  4. A class library is created using a single class Class1
  5. Rename class to Counter and add the following code.
6.  namespace CounterLibrary
7.  {
8.      public class Counter
9.      {
10.        protected int v = 0;
11.        public Counter(int v)
12.        {
13.            this.v = v;
14.        }
15.        public int Value
16.        {
17.            get
18.            {
19.                return v;
20.            }
21.        }
22.    }
23.}
  1. Save project using File->Save All. When prompted to enter location for project, select the folder where you want to save your project. I use c:\csharp. Do not select checkbox for Create directory for solution
  2. Build (not run) the project using Build->Build Solution
After the above process, we get CounterLibrary.dll assembly placed in c:\csharp\counterlibrary\bin\release directory.
The next step is to use this assembly in a console application. As a matter of fact, once a source program is converted to MSIL, it can be used anywhere in .NET, irrespective of language and type of application.
Using a private assembly in a console application developed in C#
Now, let us use the class library created in C# in a console application. Though I am using a console application in C#, you can use any language supported by .NET. 
  1. Start Visual C# 2005 Express Edition
  2. Create a new console application using File -> New Project
  3. From template select Console Application as type of project
  4. Give name UseCounter for application.
    A new application is created with a single class with Main() method.
  5. Go to Solution Explorer and select project
  6. Right click on it and select Add References from the context menu.
  7. From dialog box, select Browse tab and select c:\csharp\counterlibrary\bin\release\counterlibrary.dll
  8. Solution explorer displays counterlibrary as one of the references under references node in solution explorer
  9. Add the following code in Main() method of Program.cs
10.using System;
11.namespace UseCounter
12.{
13.    class Program
14.    {
15.        static void Main(string[] args)
16.        {
17.            counterlibrary.Counter c = new counterlibrary.Counter(100);
18.            c.Inc();
19.            Console.WriteLine(c.Value);
20.        }
21.    }
22.}
As you do the above, you can notice that a copy of counterlibrary.dll is copied into BIN directory of UseCounter application. This is the case with any private library. Whenever an application makes a reference to it, a copy of private assembly is copied into it's bin directory.

If you do not see .DLL file that is copied to BIN directory of console application (UseCounter), close the application and reopen it.

Making a private assembly a global assembly
A global assembly is a public assembly that is shared by multiple applications. Unlike private assembly, a global assembly is not copied to bin directory of each application that references it. Global assembly instead is placed in GAC (Global Assembly Cache) and it can be referenced anywhere within the system. So only one copy is stored, but many applications can use that single copy.
In order to convert a private assembly to global assembly, we have to take the following steps.
  • Create a strong name
  • Associate strong name with assembly
  • Place assembly in GAC
Creating a strong name
Any assembly that is to be placed in GAC, must have a strong name. Strong name is a combination of public key and private key. The relationship between public and private keys are such, given one you cannot get the other, but any data that is encrypted with private key can be decrypted only with the corresponding public key.
Take the following steps to invoke SN (Strong Name) tool to create strong name.
  1. Go to command prompt using Microsoft .NET Framework SDK v2.0 -> SDK Command prompt
  2. Go to c:\csharp\counterlibrary folder and enter the following command.
3.  sn -k srikanth.key
  1. The above command writes private and public key pair into srikanth.key file.
Associate strong name with assembly
Once private and public keys are generated using SN tool, use the following procedure to sign counterlibrary with the key file.
  1. Open counterlibrary project.
  2. Select project properties using Project -> counterlibrary properties
  3. Select Signing tab in project properties window
  4. Check Sign the assembly check box
  5. Select srikanth.key file using Choose a strong name key file combo box
  6. Close properties window
  7. Build the solution again using Build->Build Solution
Now, counterlibrary.dll is associated with a public key and also digitally signed with private key. This ensures no one can modify this assembly as any change to assembly should re-sign the assembly with private key of the user who created it first. This protects the assembly from getting tampered with by others. A global assembly needs this projection as it is placed in common place.
You can verify whether the assembly is associated with public key using ILDASM (IL Disassembler) program provided by .NET Framework.
  • Start ILDASM using .NET Framework SDK v2.0->Tools->MSIL Disassembler
  • Select counterlibrary.dll using File->Open
  • Once assembly is opened, double click on Manifest section of the assembly to see the public key associated with the assembly.
Place assembly in GAC
In order to make an assembly a global assembly, the assembly must be associated with a strong name and then placed in Global Assembly Cache (GAC).
GAC is a folder with name Assembly in windows folder of your system. So, place counterlibrary.dll in GAC using GACUTIL tool as follows.
c:\csharp\counterlibrary\bin\Release>gacutil -i counterlibrary.dll
After you install global assembly into GAC, you can see counterlibrary.dll in windows/assembly folder.
Once, you place an assembly in GAC, any reference to the assembly will not create a copy of the assembly in BIN directory of the application. Instead all application that reference the assembly use the same copy that is placed in GAC. 


Wednesday, May 2, 2012

ASP.NET Page Life Cycle in Depth With Example

ASP.NET Page Life Cycle in Depth With Example:-

Use of Events in Page Life Cycle:-

 
Page life cycle in asp.net is the starting of asp.net. Any developer who is working in ASP.Net platform knows about page life cycle of asp.net. The idea behind of creating this article is to demystify the ASP.Net page life cycle events. Most of the developers are pretty well aware of ASP.Net page events, but who are not, this article is definitely for them (tagline as always J ). As a developer I always got confused about page life cycle events, so I thought to understand them by going through them one by one, believe me it’s always a Pandora’s Box for me to understand. We will go through one by one to almost each event in page life cycle with examples wherever applicable.

PreInit: PreInit is the first phase in asp.net page life cycle events. This is the place where one can dynamically set their master page in the code. In such case you can also set any theme or skin to your page, in PreInit we can also set the properties of the server controls of Master page, like the code below:

protected void Page_PreInit(object sender, EventArgs e)
{
if (TextBox1 == null)
       {
          Response.Write("Pre Init, server control Not available");
       }
       else
       {
          string TextinInit = TextBox1.Text;
          Response.Write("Pre Init, Server Control enabled");
       }

Page.MasterPageFile = "~/TestInitMaster.master";

       TextBox _mstTextBox = (TextBox)Page.Master.FindControl("txtMessage");
       Label _mstLabel = (Label)Page.Master.FindControl("lblMessage");

       _mstLabel.Text = "Setted in default page at time : " + ateTime.Now.ToString();
       _mstTextBox.Text = "Textbox set in default page";
  }

In above you can see I’ve used a master page dynamically and set a label and TextBox’s Text property of that master page in runtime that means we can set the master page dynamically and associate the values in their controls if any. If you try to set the masterpage in any other event after Page_PreInit event, you will get an error message that will tell you that the master page only can be set on or before Page_PreInit event. In Page_PreInit event you can also see at the top level I’m checking a TextBox1 value whether it’s null or not. It is a server control (TextBox), but in PreInit the value will always be null of this text box or any other server control. So if I want to conclude the thing, in Page_PreInit controls are not fully initialized. So use this event for setting MasterPage file in your code. Each control Unique ID’s are also available at this event.

Init: Init is the call when you can initialize your page controls, this is the place that comes into picture after each Control initialization, till this event they get their Unique Id, master page etc. In Init you cannot access any controls properties after the last viewstate, I mean suppose you enter some text in a textbox control and click on a button control that makes a postback, now you want to view the value latest entered. In such case you will be able to see the textbox value which you’ve entered after the round trip happens, this is because of ViewState property of controls. That means they preserved your last saved value, but you see this value after Init phase because, usually we don’t use these events in our code and use just Page_Load event where the Viewstate value already got loaded. But as in Init phase, we cannot access our latest entered values in textbox, so in Init you won’t be able to get the latest changes. So I can say in Init we won’t be able to get the postback value.

InitComplete: in this event, Viewstate functionality is turned on for server control. Viewstate of controls allows preserving their values across postback.

PreLoad: This is the first event where viewstate[] functionality starts retrieving their values. PreLoad executes after InitComplete method. In this method, page has loaded values from viewstate. So for example in a button click event if you create a viewstate like below than what will gonna happen?:

protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ViewState["myData"] = "just a text string";
        }

After button click, postback will happen at it will start calling page events like PreInit, Init, Initcomplete. Till these three events you will not be able to get the value of viewstate “myData”. Even when the event fires PreLoad event of page, at this time you cannot access the ViewState, this is because ViewState will set the value when asp.net reaches the ButtonClick event, and this will happen after Load event, so one more time we will click on our submit button, and because now the ViewState[“myData”] resides into my page, I can access it on my PreLoad event. For better understanding please see the screen shot below:

 
As you can see you got the viewstate for the very first time in PreLoad event of page.
Load: Most of the developers are familiar with the page load, as this is the only event that comes by default in aspx.cs page when you start doing anything with your code behind. The page Load events executes after the Page_PreLoad event. If you have created your own Load method in constructor of your code behing, then this will be the method that will execute before the Page_Load event and after Page_PreLoad event, for better understanding refer to the image below:


As you can see in the above code, I’ve created my own Load event in my code behind as well as the default Load event, I didn’t mention Page_PreLoad event here, but it will execute after Page_InitComplete event. So back to the image, the _Default_Load will execute first before the Page_Load event. If you have any master page in your page, then the Load event of your master page will run followed by the user control Load event if they exist in your file.

Events: after the load fires, the next event that will be called in page event processing is Page Control’s event. For example, if you have a control that raises postback just like button, and you clicked on the Button, so after Page_Load your Button_Click event will fire, and do the rest of the thing you’ve mentioned in your page. for better understanding please refer to the image below, event execution will be happen in that sequence how image is showing, in event portion whatever you will do that will go ahead and will do the things you’ve mentioned in you page. just like below, I said to create a ViewState[“myData”] and put some string inside that viewstate. So now the viewstate is ready to preserve ahead in my code. 



In Events you can also check the Page.IsValid property if you’ve used any validator controls in your page like regularexpressionValidator, requiredFieldValidator, Range etc. To check this property refer to the image below.


LoadComplete:  This event can be used when all the event processing has been done in the page. I didn’t drill this event too much J

PreRender/PreRenderComplete: PreRender event gets called when page has created all the controls that user will see in his browser. PreRenderComplete is the last place to change anything in the page. After this event any changes will not get preserved in page cycle. 

SaveStateComplete: This event gets fired immediately after the PreRenderComplete event, in this event the viewstate functionality and control state get saved, as I said in PreRenderComplete changes can be done that will affect the next postback. In SaveStateComplete you can do the changes in your server control, but the state won’t be available in next postbacks.  

Render: Render is not an event but this is the phase where the HTML of your page will get rendered to the output stream with the help of HTMLTextWriter. You can override the Render method of page if you want to write your own code rather than the actual HTML text. As like below:


As you can see in the code above, I’ve override the Render method in my code and write something with Heading 1 tag and later on called the base.render method. In current scenario the thing will happen is: apart my server controls code in my browser I’ll be able to see my Hello world text also. If I remove the base.render method calls, than I won’t be able to view my any control if I’ve created in page.


Unload: This is the last event that gets fired. This is the page cleaning process like closing the open file connections etc, so in this process you cannot do any kind of manipulation with data that affect the rendering, you are restricted to use Response property also, and doing such you will get an exception message below:


 
This is what my knowledge about Page Life cycle events, I know I’ve missed certain things, but this will give you a nice idea about page events, any kind of issues, problems or some typo please leave your comment. Thank you for reading this post..