using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Web;
using System.IO;
using System.Net;
namespace ConsoleExample
{
class LoadAssembly
{
public void LoadAssembly_FromFile()
{
Assembly Ass = System.Reflection.Assembly.LoadFrom(“D:\\Parthiban\\ConsoleExample\\CrystalDecisions.Shared.dll”);
Type Asstype = Ass.GetType();
#region Get Constructor Info
ConstructorInfo[] I = Asstype.GetConstructors();
#endregion
#region Extractiong Properties Info
PropertyInfo[] PrInfo = Asstype.GetProperties();
#endregion
#region Extracting Method Info
MethodInfo[] MeInfo = Asstype.GetMethods();
Console.WriteLine(“Return Parameter \t” + MeInfo[0].ReturnType);
Console.WriteLine(“Name \t” + MeInfo[0].Name);
Console.WriteLine(“Module \t” + MeInfo[0].Module);
Console.WriteLine(“Method Body \t” + MeInfo[0].GetMethodBody());
Console.ReadLine();
#endregion
#region Extracting Event Info
EventInfo[] EveInfo = [...]
Archive for July, 2008
To Read a Assembly file using Reflection in C#.NET
July 20, 2008Cookiless Session State in ASP.NET
July 20, 2008When each user browse a Page the unique Session Object is created….Session Object is idendified by unique session Id.
The Session ID is Sent back to the client in the form of cookies.
Some browser does not support cookies.. So that we can set cooliless=true.
For that… the Session ID Sent to the URL QueryString.
Passing Object Reference to a Function
July 20, 2008While Passing reference to the function any changes made to that variables inside the Function.That will affect the
Main variable value.
—————————————–
When we can Pass it object value as variables it just make a Copy of that variables…… and than it takes to perform
an operation.But while passing the reference Both variables are refer to the same memory [...]
Overloaded Constructor in C#.NET
July 20, 2008A class can have any number of constructor.
OverloadConstructor is nothing but the Constructor having different set of parameters.
1.Under this type of situation ,how to call one Constructor to another constructor.
For the below Example when creating Object to the Parameter 2 Constructor it automatically redire
-ct to the Parameter 3 Constructor.The Parameter 2 Constructor wont’t called
///////////////////////////////////////////////////////////////////////////////////////////
using System;
using [...]
To Call a Base Class Constructor From Derived Class Constructor Calling in C#.NET
July 20, 2008class CheckStatic:NewKeyWord
{
public CheckStatic():base()
{
Console.WriteLine(“I am a Derived Class Constructor”);
}
public void CheckStatic1()
{
base.GetData1();
}
}
///////////////////////////////////////////
Use the (Base) Keyword to call a Base Class Constructor.
Basic 64-bit Encoding and Decoding in C#.NET
July 20, 2008byte[] Keybyte = new byte[Key.Length];
System.Text.ASCIIEncoding Encoding = new System.Text.ASCIIEncoding();
return Convert.ToBase64String(Encoding.GetBytes(Key) );
///// U can also use it to convert string to Bytes.
Short Method:
string OrderCode = “Ord12011982″;
#region Encode
byte[] Enc = ASCIIEncoding.UTF7.GetBytes(OrderCode);
string EncString = Convert.ToBase64String(Enc);
#endregion
#region Decode
byte[] Dec = Convert.FromBase64String(EncString);
string b = ASCIIEncoding.UTF7.GetString(Dec);
#endregion
Tou can al use UTF8,UTF32
To Change the gridview lines color in ASP.NET
July 20, 2008<asp:DataGrid ID=”DataGrid1″ runat=”server” AutoGenerateColumns=”False”
BorderColor=”Black” BorderStyle=”Solid” BorderWidth=”1px” Width=”300px” PageSize=”7″>
<Columns>
<asp:TemplateColumn ItemStyle-BorderColor=”blue” ItemStyle-BorderStyle=”solid” ItemStyle-BorderWidth=”2px”>
<ItemTemplate>
<center>
<asp:Label ID=”Label1″ runat=”server” Text=’Hello’></asp:Label>
</center>
</ItemTemplate>
<HeaderStyle HorizontalAlign=”Center” />
</asp:TemplateColumn>
<AlternatingItemStyle BackColor=”Gainsboro” BorderColor=”White” />
<HeaderStyle BackColor=”Gray” />
<EditItemStyle BorderColor=”White” />
<ItemStyle BorderColor=”White” />
</asp:DataGrid>
Region Based Default Button in ASP.NET
July 20, 2008EmailTextBox.Attributes.Add(“onKeyPress”, “javascript:if (event.keyCode == 13) __doPostBack(‘” + LoginButton.UniqueID + “‘,”)”);
Another one Simple Method is use the Panel inside it put the Default Button Focus To It
<asp:Panel ID=”Hi” runat=”server” DefaultButton=”Button1″>
You can also kept the focus coding at the Form tag itself
<form id=”form1″ runat=”server” defaultbutton=”Button3″ >
Transaction in C#.NET
July 20, 2008SqlConnection conn = new SqlConnection(connString);
SqlTransaction trans = conn.BeginTransaction();
try
{
SqlCommand cmd = new SqlCommand(“MyWriteProc”,conn, trans);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(….
…
// additional transactioned writes to database
trans.Commit();
}
catch
{
trans.Rollback();
}
When you use ADO.NET manual transactions, you can set the desired isolation
level on the BeginTransacion method as shown in the following code fragment.
SqlConnection conn = new SqlConnection(connString);
SqlTransaction trans = conn.BeginTransaction(IsolationLevel.ReadCommitted);
To Send an XML stream to another Page in ASP.NET
July 20, 2008using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.Net;
public partial class SendStream : System.Web.UI.Page
{
HttpWebRequest MyRequest;
#region Page_Load
protected void Page_Load(object sender, EventArgs e)
{
}
#endregion
#region Send_Stream
protected void Button1_Click(object sender, EventArgs e)
{
try
{
using(SqlConnection SQLCon = new SqlConnection(“server=.;database=TEST;user id=sa;password=sa”))
{
SQLCon.Open();
string Str = “SELECT * FROM CATEGORY AS CATEGORY”;
SqlCommand SQLCmd = new SqlCommand(Str, SQLCon);
DataSet Ds = [...]