Ağu 14 2009

ASP.Net AJAX Not Working (Full page postback)

Category: Ajax | ASP.NETLatif @ 15:45

 Hi,

After carrying my web application to windows server 2003 R2 from windows  XP - IIS 5.1,  I have encountered a ASP.Net AJAX issue that my page is performing a full page postpage instead of a partial page postback of the expected AJAX page elements.

        I have searched everywhere, and this is the only solution I can find.  I just stumbled upon this page below and I applied what it is saying.  I would like to thank to Neil kilbride for sharing this solution with us.

http://neilkilbride.blogspot.com/2008/01/aspnet-ajax-not-working-full-page.html

Solution :

I just added to my web.config file following code to solve the problem.

   <system.web>

        <xhtmlConformance mode="Transitional" />

  </system.web>

 And also he says thatIf you are having ASP.Net AJAX issues I recommend removing the <xhtmlConformance> section from your web.config file or perhaps set it to Transitional or Strict.

 

Tags: ,

Haz 19 2009

Call Crystal report from ASP.Net & Changing connectionInfo of Crystal report at runtime

Category: ASP.NET | Crystal ReportLatif @ 17:57

 Code with descriptions: file.cs

    try

    {

        //Get params from QueryString

        string startdate = context.Request.QueryString["StartDate"];

        string enddate = context.Request.QueryString["EndDate"];

        //Define report format

        context.Response.ContentType = "application/pdf";

 

        ReportDocument crReport = new ReportDocument();

        crReport.Load(context.Server.MapPath("rpRevenueSharingAll.rpt"));

        //Set the parameters

  crReport.SetParameterValue(0, startdate); //STARTDATE

        crReport.SetParameterValue(1, enddate);//ENDDATE

       

        //Retrieve Web.config's connection string information

        string connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

        SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectionString);

        string password = builder.Password;

        string username = builder.UserID;

        string dataSource = builder.DataSource;

        string initialCatalog = builder.InitialCatalog;

 

        //Define new connection for Crystal Report

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

        connectionInfo.DatabaseName = initialCatalog;

        connectionInfo.UserID = username;

        connectionInfo.Password = password;

        connectionInfo.ServerName = dataSource;

 

        // set report connection for main report

        SetDBLogonForReport(connectionInfo, crReport);

        // set report connection for any subreports

        SetDBLogonForSubreports(connectionInfo, crReport);

 

        MemoryStream ms = (MemoryStream)crReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

        context.Response.BinaryWrite(ms.ToArray());

 

    }

    catch (System.Threading.ThreadAbortException ex)

    {

       

    }

    finally

    {

        context.Response.End();

    }

 You can see the functions I have used above. I found the functions from http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=1249&PID=4186

        private void SetDBLogonForReport

          (CrystalDecisions.Shared.ConnectionInfo connectionInfo,

            ReportDocument reportDocument)

        {

 

            Tables tables = reportDocument.Database.Tables;

            foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)

            {

                TableLogOnInfo tableLogonInfo = table.LogOnInfo;

                tableLogonInfo.ConnectionInfo = connectionInfo;

                table.ApplyLogOnInfo(tableLogonInfo);

            }

        }

 

        private void SetDBLogonForSubreports

          (CrystalDecisions.Shared.ConnectionInfo connectionInfo,

           ReportDocument reportDocument)

        {

            Sections sections = reportDocument.ReportDefinition.Sections;

            foreach (Section section in sections)

            {

                ReportObjects reportObjects = section.ReportObjects;

                foreach (ReportObject reportObject in reportObjects)

                {

                    if (reportObject.Kind == ReportObjectKind.SubreportObject)

                    {

                        SubreportObject subreportObject = (SubreportObject)reportObject;

                        ReportDocument subReportDocument =

                          subreportObject.OpenSubreport(subreportObject.SubreportName);

                        SetDBLogonForReport(connectionInfo, subReportDocument);

                    }

                }

            }

        }

 

Tags: ,

Haz 18 2009

Retrieve individual data from ConnectionString

Category: ASP.NETLatif @ 18:04

   If you want to retrieve data(password ,UserID,DataSource,InitialCatalog) , you can use SqlConnectionStringBuilder (From .NET Framework 2.0, there is System.Data.Common.DbConnectionStringBuilder  and its derived classes (SqlConnectionStringBuilder for SqlServer))

string connectionString = WebConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectionString);

string password = builder.Password;
string username = builder.UserID;
string dataSource = builder.DataSource;
string initialCatalog = builder.InitialCatalog;

 

Tags: ,

Haz 12 2009

LINQ: Max

Category: ASP.NET | LINQLatif @ 16:47

LINQ da SQL deki max islemini nasil mi yapariz?

Asagidaki sekilde,

MDDBDataContext dc = new MDDBDataContext();

var lastNumber = (from r in dc.RevenueSharings
                                  select (int?)r.StatementNumber).Max();

 

SQL server profiler tarafinda asagidaki sekilde goreceksiniz...

SELECT MAX([t0].[StatementNumber]) AS [value]
FROM [dbo].[RevenueSharing] AS [t0]

Tags: , , ,