Thursday, June 23, 2011

The difference between <%= and <%# in ASP.NET



http://blogs.msdn.com/b/dancre/archive/2007/02/13/the-difference-between-lt-and-lt-in-asp-net.aspx


•The <%= expressions are evaluated at render time
•The <%# expressions are evaluated at DataBind() time and are not evaluated at all if DataBind() is not called.
•<%# expressions can be used as properties in server-side controls. <%= expressions cannot.

Do you need to use ResolveUrl for href ?

ALMOST NO.

WCF : IMPORTANT : BE CAREFUL WHEN RETURNING A DATATABLE : ALWAYS NAME THE TABLE

If a web method in a wcf service is returning a DataTable, the DataTable must be given a name :


 
 Public Function ValidateUser(ByVal UserId As String, ByVal Password As String) As DataTable Implements ILoginService.ValidateUserDim retval As Boolean = FalseDim dtTemp As New DataTable("ReturnTable")Dim cmd As New SqlCommandcmd.CommandType =
cmd.CommandText =
CommandType.StoredProcedure"ValidateUser"cmd.Parameters.AddRange(
{

})
cmd.Connection =
cmd.Connection.Open()
dtTemp.Load(cmd.ExecuteReader())
cmd.Connection.Close()


New SqlParameter() _New SqlParameter("UserId", UserId), _New SqlParameter("Password", Password) _New SqlConnection(connstr)Return dtTempEnd Function



Other wise you may get an error something like this :

An existing connection was forcibly closed by the remote host



Exception Details: System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

Dim dtTemp As New DataTable("ReturnTable")


OPEN QUESTION : Are static classes provided default static constructor by compiler ?

ALMOST "NO".

http://msdn.microsoft.com/en-us/library/ms173115(v=vs.80).aspx
Unless the class is static, classes without constructors are given a public default constructor by the C# compiler in order to enable class instantiation.

http://msdn.microsoft.com/en-us/library/79b3xss3(v=vs.80).aspx
Static classes cannot contain a constructor, although it is still possible to declare a static constructor to assign initial values or set up some static state.

The first statements almost makes it clear, although it is not mentioned clearly anywhere that default static constructors are NOT provided by compiler to static classes.


Another intersesting thing, what if both a derived and base class have static constructors ?
see this : http://msdn.microsoft.com/en-us/library/k9x6w0hc(v=vs.80).aspx

Static constructor of derived class is called before base class's static constructor
When base class and derived class both have static contructors, then first derived class static constructor is called and then base class static constructor is called. (In C#.NET 2.0)
This is exactly opoosite to the instance constructor hierarchy.

Method Overloading is done only by parameter types, not by return types




{

}


int Meth(int a, int b)return 0;//compile time error //Error 1 Type 'Class1' already defines a member called 'Meth' with the same parameter types //long Meth(int a, int b)//{// return 0;


 //VALID
{

}


//VALID//NOTE : EVEN A RETURN TYPE OF LONG IS ALSO VALID
{

}
int Meth(string b, int a)return 0;
int Meth(int a, string b)return 0;  
//}

Comparing features of LangGraph vs CrewAI

LangGraph Orchestration vs CrewAI Orchestration The following table compares LangGraph and CrewAI orchestration across their menta...