Sunday, November 28, 2010

Textual description of firstImageUrl

How to view ASP.NET trace information

You can enable ASP.NET tracing either at an Application level or at a page level.

With the tracing enabled, you can view the trace output in a trace viewer by navigation to trace.axd from the root of your application. For example, if the URL of your application is http://localhost:11423/Website, then the trace viewer can be accessed at http://localhost:11423/WebSite1/trace.axd.

Trace

You can click on the “View Details” link of a requested page to see further information about that specific page.

To write to the trace output, you can add the statement Trace.Write(“This is an action in my page.”) into your code.

The trace request limit and whether the most recent tracing data is kept and shown in the viewer can be specified in the web.config file as follows:


<system.web>
<trace enabled=”true” mostRecent=”true”
pageOutput=”true” requestLimit=”20” />



Dynamic Create DataTable from Generic List using Reflection

I have few methods that returns different Generic Lists.But main thing here I am using Reflection to convert Generic List into Datatable.

public static DataTable ListToDataTable<T>(List<T> list)
{
DataTable dt = new DataTable();

foreach (PropertyInfo info in typeof(T).GetProperties())
{
Type pt = info.PropertyType;
if (pt.IsGenericType && pt.GetGenericTypeDefinition() == typeof(Nullable<>))
{
pt = Nullable.GetUnderlyingType(pt);
dt.Columns.Add(info.Name, pt);
}
else
dt.Columns.Add(new DataColumn(info.Name, info.PropertyType));
}
foreach (T t in list)
{
DataRow row = dt.NewRow();
foreach (PropertyInfo info in typeof(T).GetProperties())
{
row[info.Name] = info.GetValue(t, null);
}
dt.Rows.Add(row);
}
return dt;
}

Tuesday, October 12, 2010

Dynamic Crystal Report Connection String Using Asp.net



 



Dynamic crystal report connection string required for transfer application dev to test.Normally developer working in devlopment server and after complet the development it will deploy the application into TEST or Production Server .In this case crystal report have not worked if you are specially using oracle stored procedure .Here I explain you how to create function for dynamic connection with stored procedure.














using CrystalDecisions.CrystalReports.Engine; 


using CrystalDecisions.Shared; 



 



public ReportDocument ConnectionInfo(ReportDocument rpt)
{
ReportDocument crSubreportDocument;
string[] strConnection = ConfigurationManager.ConnectionStrings[("AppConn")].ConnectionString.Split(new char[] { ';' });

Database oCRDb = rpt.Database;

Tables oCRTables = oCRDb.Tables;

CrystalDecisions.CrystalReports.Engine.Table oCRTable = default(CrystalDecisions.CrystalReports.Engine.Table);

TableLogOnInfo oCRTableLogonInfo = default(CrystalDecisions.Shared.TableLogOnInfo);

ConnectionInfo oCRConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo();

oCRConnectionInfo.ServerName = strConnection[0].Split(new char[] { '=' }).GetValue(1).ToString();
oCRConnectionInfo.Password = strConnection[2].Split(new char[] { '=' }).GetValue(1).ToString();
oCRConnectionInfo.UserID = strConnection[1].Split(new char[] { '=' }).GetValue(1).ToString();

for (int i = 0; i < oCRTables.Count; i++)
{
oCRTable = oCRTables[i];
oCRTableLogonInfo = oCRTable.LogOnInfo;
oCRTableLogonInfo.ConnectionInfo = oCRConnectionInfo;
oCRTable.ApplyLogOnInfo(oCRTableLogonInfo);
if (oCRTable.TestConnectivity())
//' If there is a "." in the location then remove the
// ' beginning of the fully qualified location.
//' Example "dbo.northwind.customers" would become
//' "customers".
oCRTable.Location = oCRTable.Location.Substring(oCRTable.Location.LastIndexOf(".") + 1);


}

for (int i = 0; i < rpt.Subreports.Count; i++)
{

{
// crSubreportObject = (SubreportObject);
crSubreportDocument = rpt.OpenSubreport(rpt.Subreports[i].Name);
oCRDb = crSubreportDocument.Database;
oCRTables = oCRDb.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table aTable in oCRTables)
{
oCRTableLogonInfo = aTable.LogOnInfo;
oCRTableLogonInfo.ConnectionInfo = oCRConnectionInfo;
aTable.ApplyLogOnInfo(oCRTableLogonInfo);
if (aTable.TestConnectivity())
//' If there is a "." in the location then remove the
// ' beginning of the fully qualified location.
//' Example "dbo.northwind.customers" would become
//' "customers".
aTable.Location = aTable.Location.Substring(aTable.Location.LastIndexOf(".") + 1);

}
}
}
// }

rpt.Refresh();
return rpt;
}



 






This will not work with oracle packages.

PDF Arabic watermark using MVC and iTextSharp

PDF full page Arabic watermark using MVC and iTextSharp Download :  Source Code Most of the time we have requirement to  gen...