11 September 2008

Main Bowling

Foto main bowling bareng.

08 July 2008

Install AjaxControlToolkit for VS 2008

Install AjaxControlToolkit for VS 2008
I am crying to develop ASP.NET using VS 2008 because that have limited control.
after download ajaxcontrol from http://asp.net I am happy because i get control for development.
1. Download for framework 3.5 ajaxcontrol from http://asp.net
2. Extract this file to C:\Program Files\Microsoft ASP.NET Ajax Extention.
3. Open your Visual Studio 2008.
4. Add tab in your toolbox and give toolbox name "AJAX Toolkits".
5. Choose Item and browse to your folder.
example : "C:\Program Files\Microsoft ASP.NET Ajax Extention\SampleWebSite\Bin\AjaxControlToolkit.dll"
6. Now you can see new component in "AJAX Toolkits"

Now you can use new component for your web application like datepicker, cascading dropdwon and more.
dot forget use this tag in your code.

Example using Calender Extender:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<ajaxToolkit:ToolkitScriptManager runat="Server" EnableScriptGlobalization="true" EnableScriptLocalization="true" ID="ScriptManager1" />

<asp:TextBox ID="TxtUntil" runat="server" MaxLength="10" Width="80px"></asp:TextBox>
<asp:ImageButton ID="ImgUntil" runat="server" ImageUrl="~/images/Calendar_scheduleHS.png" AlternateText="Click to show calendar" />
<ajaxToolkit:CalendarExtender ID="CalExUntil" Format="dd-MM-yyyy" runat="server" PopupButtonID="ImgUntil" TargetControlID="TxtUntil"> </ajaxToolkit:CalendarExtender>

04 July 2008

Simple using LINQ for read XML file

I have xml format for store connection attribute.
<configuration>
<profile>
<host>my host</host>
<dbnm>Database Name</dbnm>
<usernm>User name</usernm>
<pwd>My PAssword</pwd>
</profile>
</configuration>


How to read this xml file ?. I try with new technologi from Microsoft.
I am using LINQ.

using System.Xml;
using System.Xml.Linq;

var custs = from c in XElement.Load("dbprofile.xml").Elements("profile")
where c.Element("host").Value == "DATABASE"
select c;

foreach (var customer in custs)
{
Console.WriteLine("Host : " + customer.Element("host").Value);
Console.WriteLine("Database : " + customer.Element("dbnm").Value);
Console.WriteLine("User Name : " + customer.Element("usernm").Value);
Console.WriteLine("Password : " + customer.Element("pwd").Value);
}


Console.ReadLine();


enjoyy

Problem 'Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

I have problem when deploy from development to production server.
The problem is "Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies." in the web.config. For your information i was installed .NET Framework 3.5 because I am using visual studio 2008.
But the project not running well and then i googling ahah i got the clue from a blog.

He said please download for ReportViewer.exe
http://www.microsoft.com/downloads/details.aspx?FamilyID=CC96C246-61E5-4D9E-BB5F-416D75A1B

problem solve

02 July 2008

Client-Side Reporting with Visual Studio in C#

Yesterday i was try produce report by Crystal Report. Now i am using Client Side Report for my ASP.NET project.
The first drag and drop Microsoft Report Viewer to your web form. Give the id is RptViewer.
Create New DataSet, define the coloumn do you need. For example TblXXX(cola,colb).

dont forget for include namespace for (System.Data.SqlClient and Microsoft.Reporting.WebForms).
//namespace
using System.Data.SqlClient;
using Microsoft.Reporting.WebForms;




String VarSQL;
SqlDataAdapter VarRst;
DataSet ds = new DataSet();


//Define object for connection to DB you can create by your self.
ClassDB.ClassToDB db = new ClassDB.ClassToDB();

VarSQL = "SELECT cola,colb FROM Tblzzz";


//result from method ExecuteDataAdapter is Data Adapter
VarRst = db.ExecuteDataAdapter(VarSQL);
VarRst.Fill(ds, "report");

ReportDataSource dataSource = new ReportDataSource("DataSet1_TblXXXX", ds.Tables[0]);
RptViewer.Reset();
RptViewer.LocalReport.ReportPath = Server.MapPath("rpt/rpt_fuel.rdlc");
RptViewer.LocalReport.DataSources.Add(dataSource);

01 July 2008

Send mail in .NET

This is simple code for send to email using C#.
please add your namespace,
using System.Net.Mail;

//create mail object
MailMessage mail = new MailMessage();
mail.From = new System.Net.Mail.MailAddress("email@emailaddress.com");
mail.Subject = "Subject";
mail.Body = "This is Body,"+"\r\n";


//Define your SMTP
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("mail.mail.co.id");
smtp.Send(mail);


"\r\n" this code for new line.

24 June 2008

Using Crystal Report in ASP.NET

Yesterday I am looking for access crystal report by C#. This is step by step how to make report until display report by crystal report viewer.
1. Define element data using DataSet. Create new item -> DataSet. This is like XML format.Double click DataSet1.xsd and drag and drop DataTable. Define elemen data for report.
2. Create new crystal report file. Create using report wizard -> Create New Connection -> ADO.NET(XML) -> File path using DataSet1.xsd -> Next...next until finsih the process.
3. Now, ceate new web form. Drag and Drop the Crystal Report Viewer from toolbox.
4. How to bind ?

private void BindReport()
{
String VarSQL;
SqlDataAdapter VarRst;
DataSet ds = new DataSet();
CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

ClassDB.ClassToDB db = new ClassDB.ClassToDB();
VarSQL = "SELECT Cola,colb FROM tablename";
oRpt.Load(Server.MapPath("rpt/rpt_fuel.rpt"));
VarRst = db.ExecuteDataAdapter(VarSQL);
VarRst.Fill(ds, "report");


oRpt.SetDataSource(ds.Tables["report"]);
RptViewer.Visible = true;
RptViewer.ReportSource = oRpt;
RptViewer.DataBind();
}

Method ExecuteDataAdapter this is function from ClassDB the result is SqlDataAdapter.

I hope this step useful for your code.

23 June 2008

Memilih bahasa pemograman di .NET

Banyak pertanyaan yang muncul ketika saya mau memulai dengan pemograman .NET.
Bahasa pemograman apaan yang akan dipakai VB.NET atau C# sudah gitu mau desktop
atau web base.

Pertimbangan yang saya ambil yaitu :
1. Saya memilih C# kenapa?, ya karena itu baru buat saya walaupun bahasanya mirip dengan PHP. Trus kenapa gak pake VB.NET? Udah terlalu lama saya menggunakan VB rasa pengen yang baru biar gak terlalu jenuh waktu programming.

2. Pilih deksctop atau web base nah kalau yang ini bukan pilihan tetapi saya akan pilih dua-duanya. Kenapa? Programmer itu pada dasarnya tidak dibatasi oleh dekstop atau web base application.
Dia harus bisa mengimplentasikan suatu bisnis logic sesuai kebutahan sekarang dan nanti.

3. Visual Studio .NET versi berapa yang diapakai? Saya sarankan versi 2008 karena disitu ada technologi baru yaitu LINQ.

Sekian saja mudah-mudahan yang lagi bingung memilih tambah bingung lagi.