Friday, July 27, 2012

Get checkboxlist selecte items in a string with comma seprated

this is code to get  selected items in checkbox list as a string separated with comma or any delimeter you want to use like |(Pipe singn)

var selectedValues = (from item in chbBroadType.Items.Cast() where item.Selected select item.Value).ToArray();
var selectedValuesJoined = string.Join(",", selectedValues);

Get count of checkboxlist selected items

this is single line of code that can be used to get the number of items selected in checkboxlist in asp.net with c#

int count= ChbProperty.Items.Cast<ListItem>().Count(li => li.Selected);

Sunday, July 22, 2012

parthavi new photos (cool without hair )

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

parthavi atri

How to get java script variable value on server side

The answer is Hidden field or any input control.

You just need to take hidden field and set the value of  java script variable on hidden filed .like below

var javascriptvariable='some value'; 
$('#hiddenfield').val(javascriptvariable);
 
 
Now on server side you can get the hidden field which is 
actually java script variable  value 
 
String hdnvalue=hiddenfield.value;
 
I have used Jquery val function to set the value .
 You can use val function of jquery  in
two ways to get the value just use the 
 $('#hiddenfield').val(
 
and for setting the value you need to pass 
the value as argument in val function 
like this 
 
 
 $('#hiddenfield').val('31october') 
 alert($('#hiddenfield').val() );
 
 
you can check live demo here .
 
http://jsfiddle.net/VaKfP/255/
 
 
 I love http://jsfiddle.net/  for jquery code sharing.  
 
 
Thanks   

Friday, July 6, 2012

get the dropdown value and text using jquery

we have a drop down an ID, Name Pair.
Example

Rahul has ID of 1
Chand has ID of 2
Parthavi has ID of 3
When I do the followng:
alert($('#Crd').val());
and we select Rahul , we get 1

but in case we want selected text in jquery for a dropdown
then

$('#dropdownId option:selected').text();

Interview Question you might face ?

Reflection
Serialization
Stateless and statfull application
web service
jquery
json
Static Class
Static Class Inheritance
Abstract Data Type
DataAdapter and DataReader
Can we use session in Ajax

Interview Questions with answer

hi dear ,
actually these days i m bg with interviews so i m refreshing c# or asp.net concepts,so i want to share with u also these so if u go for the interview next time jst go through hope they will help u ..........

Q.1-what is interface and why its used ?

Ans.1-An interface looks like a class, but has no implementation. The only thing it contains are definitions of events, indexers, methods and/or properties. The reason interfaces only provide definitions is because they are inherited by classes and structs, which must provide an implementation for each interface member defined.
So, what are interfaces good for if they don't implement functionality? They're great for putting together plug-n-play like architectures where components can be interchanged at will. Since all interchangeable components implement the same interface, they can be used without any extra programming. The interface forces each component to expose specific public members that will be used in a certain way.
Because interfaces must be implemented by derived classes and structs, they define a contract. For instance, if class foo implements the IDisposable interface, it is making a statement that it guarantees it has the Dispose() method, which is the only member of the IDisposable interface. Any code that wishes to use class foo may check to see if class foo implementsIDisposable. When the answer is true, then the code knows that it can call foo.Dispose(). Any difference between the method signature in the interface and the method signature in the implementing class or struct will cause a compiler error. Additionally, a class or struct that inherits an interface must include all interface members; You will receive a compiler error if you don't implement all interface members.
You can implement an interface and use it in a class. Interfaces may also be inherited by other interface. Any class or struct that inherits aninterface must also implement all members in the entire interface inheritance chain.
Interfaces consist of methods, properties, events, indexers, or any combination of those four member types. An interface cannot contain constants, fields, operators, instance constructors, destructors, or types. It cannot contain static members. Interfaces members are automatically public, and they cannot include any access modifiers.

When a class or struct implements an interface, the class or struct provides an implementation for all of the members defined by the interface. The interface itself provides no functionality that a class or struct can inherit in the way that base class functionality can be inherited. However, if a base class implements an interface, the derived class inherits that implementation. The derived class is said to implement the interface implicitly.

Classes and structs implement interfaces in a manner similar to how classes inherit a base class or struct, with two exceptions:

A class or struct can implement more than one interface.

When a class or struct implements an interface, it receives only the method names and signatures, because the interface itself contains no implementations,



Q.2-difference between abstract class and interface ?

Ans.2-

Q.3-What is an Abstract Class?


Ans.3-An abstract class is a special kind of class that cannot be instantiated. So the question is why we need a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.

Q.4-What is an Interface?


ans.4-An interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class. Since C# doesn�t support multiple inheritance, interfaces are used to implement multiple inheritance.



Q.5-what is abstract class ?



Ans.5-Abstract classes are closely related to interfaces. They are classes that cannot be instantiated, and are frequently either partially implemented, or not at all implemented. One key difference between abstract classes and interfaces is that a class may implement an unlimited number of interfaces, but may inherit from only one abstract (or any other kind of) class. A class that is derived from an abstract class may still implement interfaces. Abstract classes are useful when creating components because they allow you specify an invariant level of functionality in some methods, but leave the implementation of other methods until a specific implementation of that class is needed. They also version well, because if additional functionality is needed in derived classes, it can be added to the base class without breaking code.

An abstract class is denoted in Visual Basic by the keyword MustInherit. In C#, the abstract modifier is used. Any methods that are meant to be invariant may be coded into the base class, but any methods that are to be implemented are marked in Visual Basic with the MustOverride modifier. In C#, the methods are marked abstract

When implementing an abstract class, you must implement each abstract (MustOverride) method in that class, and each implemented method must receive the same number and type of arguments, and have the same return value, as the method specified in the abstract class.



Q.6-Difference between class and structure ?

Ans.6-classes are refrence types where the structures are the value types Since classes are reference type, a class variable can be assigned null.But we cannot assign null to a struct variable, since structs are value type.
when u insitate a class it will be allocated on heap where in the case of structure its get created on stack.
when passing a class to a method it will be passed by refrence but in case we pass struct as parameter it will be passed by value.
you cannot have instance fileds intilizaries in structs but class can have.
structure does not support inheritance where class supports the inheritance.
classes are used for large and complex datasets where the structs are simple to use.

Q.7-difference between vs 2005 and vs 2008 ?

Ans.7-


Q.8-what is web service and how to used ?

Ans.8-  Web service" as "a software system designed to support interoperable machine-to-machine interaction over a network"

Q.9-difference between overloading and overriding ?

Ans.9-
 OVERLOADING :
Overloading is when you have multiple methods in the same scope, with the same name but different signatures.
Overloading is the example of compile-time polymorphism.
//Overloading
public class test{
    public void getStuff(int id)
    {}
    public void getStuff(string name)
    {}
}
OVERRIDING :
Overriding is a principle that allows you to change the functionality of a method in a child class


//Overriding
public class test{
        public virtual getStuff(int id)
        {
            //Get stuff default location
        }
}
public class test2 : test{
        public override getStuff(int id)
        {
            //base.getStuff(id);
            //or - Get stuff new location
        }
}
  Overriding is the example of run-time polymorphism




Q.10-if we have master page or contain page, and a button on contain page is clicked ,then which load method call first ?
Ans.10-
Q.11-What is marshelling ?what is the use of marsheling in c# ?
Ans.11-
Q.12-What is deligates ? How many types of deligates ?
Ans.12-
Q.13-Example of static and dynamic ploymorphism ?
Ans.13-
Q.14-Which event is occured when a grid view button is clicked ?
Ans.14-
Q15.Difference between ds.copy () or ds.clone () ?
Ans.15-The Clone method of the DataSet class copies only the schema of a DataSet object. It returns a new DataSet object that has the same schema as the existing DataSet object, including all DataTable schemas, relations, and constraints. It does not copy any data from the existing DataSet object into the new DataSet.

The Copy method of the DataSet class copies both the structure and data of a DataSet object. It returns a new DataSet object having the same structure (including all DataTable schemas, relations, and constraints) and data as the existing DataSet object.
Q.16 What is static constructor ?if i make 4 objects of any class then how many times of static constructor will be called ?

Ans.16--
Q.17-jquery ? how to use ? $ why used ?
Ans.17-
Q.18-what is clr ?
Ans.18-
Q.19 what do you understand by .net assembly ?
Ans.19-
Q.20-partial class ?
Ans.20-

Q.21-What is reflection ?
Ans.21-
Q.22-server.transfer and response.redirect ?
Ans.21-
Q.22-how u achieve abstraction in a project ?
Ans.22-

Q.23-managed code and unmanaged code ?

Ans.23-Here is some other complimentary explication about Managed code:
  • Code that is executed by the CLR.
  • Code that targets the common language runtime, the foundation of the .NET Framework, is known as managed code.
  • Managed code supplies the metadata necessary for the CLR to provide services such as memory management, cross-language integration, code access security, and automatic lifetime control of objects. All code based on IL executes as managed code.
  • Code that executes under the CLI execution environment.

Managed code is not compiled to machine code but to an intermediate language which is interpreted and executed by some service on a machine and is therefore operating within a (hopefully!) secure framework which handles dangerous things like memory and threads for you. In modern usage this frequently means .NET but does not have to.
Unmanaged code is compiled to machine code and therefore executed by the OS directly. It therefore has the ability to do damaging/powerful things Managed code does not. This is how everything used to work, so typically it's associated with old stuff like .dlls



Q.24-native code ?
Ans.24-

Q.25-sealed class ?

Ans.25-Sealed class is used to define the inheritance level of a class.

The sealed modifier is used to prevent derivation from a class. An error occurs if a sealed class is specified as the base class of another class.

Some points to remember:

1. A class, which restricts inheritance for security reason is declared, sealed class.
2. Sealed class is the last class in the hierarchy.
3. Sealed class can be a derived class but can't be a base class.
4. A sealed class cannot also be an abstract class. Because abstract class has to provide functionality and here we are restricting it to inherit.

Q.26-How to use javascript from code behind in asp.net ?
ans.26-
Page.ClientScript.RegisterStartupScript


(this.GetType(), "alert", "alertMe();", true);

Q.27-differenc between string and stringbuilder ?

ans 27.-
"The String object is immutable. Every time you use one of the methods in the System.String class, you create a new string object in memory, which requires a new allocation of space for that new object. In situations where you need to perform repeated modifications to a string, the overhead associated with creating a new String object can be costly. The System.Text.StringBuilder class can be used when you want to modify a string without creating a new object. For example, using the StringBuilder class can boost performance when concatenating many strings together in a loop."

Q.28-What is immutable ?

ans.28-an immutable object is an object whose state cannot be modified after it is created. This is in contrast to a mutable object, which can be modified after it is created.
example :-
String s = "ABC";
s.toLowerCase();

The method toLowerCase() will not change the data "ABC" that s contains. Instead, a new String object is instantiated and given the data "abc" during its construction


Q.29-how to get client side id of a textbox in javascript function in asp.net ?
ans.29-var txtBox = document.getElementbyId("<%=txtBoxSnrInsp.ClientID %>");

Q.30-What are the different parameter modifiers available in C#?
Ans.30-Parameter modifiers in C# are entities that controls the behaviour of the arguments passed in a method. Following are the different parameter modifiers in C#:
1) None - if there is NO parameter modifier with an argument, it is passed by value, where the method recieves a copy of the original data.
2) out - argument is passed by reference. The argument marked with "out" modifier needs to be assigned a value within this function, otherwise a compiler error is returned.

public void multiply(int a, int b, out int prod)
{
prod = a * b;
}

Here, note that prod is assigned a value. If not done so, then a compile time error is returned.
3) params- This modifier gives the permission to set a variable number of identical datatype arguments.
Note that a method may have only one "params" modifier. The params modifier needs to be in the last argument.

C# Example
static int totalruns(params int[] runs)
{
int score = 0;
for(int x=0; x
&nsbp;score+=runs[x];
return score;
}

Further, from the calling function, we may pass the scores of each batsman as below...

score = totalruns(12,36,0,5,83,25,26);

4) ref - The argument is given a value by the caller, where data is passed by reference. This value may optionally be reset in the called method. Note that even if NO value is set in the called method for the ref attribute, no compiler error is raised.
Q.31-What are different validation controls available in asp.net tool box ?

Source is google suggested results from different tutorial or websites....
Rahul Kumar Sharma

Change anchor tag text with jquery

To change the text with jquery simply use this syntax

 $('document').ready(function () {
        $('.txtText').click(function () {
                     alert($(this).text() ); //this will dispaly current text

                     $(this).text('new text ');//this will set new text


         });
    });

How to know your jquery version

To check your jquery version just alert this message.

alert($.fn.jquery);

and you will see your jquery version



Sunday, July 1, 2012

how to pass multiple values in commandargument

 ShowHeader="false">
    
        
          
       
 
 
 
protected void gridview_RowCommand(object sender, GridViewCommandEventArgs e)
{
      string[] arg = new string[2];
      arg = e.CommandArgument.ToString().Split(';');
      Session["IdTemplate"] = arg[0];
      Session["IdEntity"] = arg[1];
      Response.Redirect("Samplepage.aspx");
}
 

ASP.NET Core

 Certainly! Here are 10 advanced .NET Core interview questions covering various topics: 1. **ASP.NET Core Middleware Pipeline**: Explain the...