Ask a Question related to Dreamweaver AppDev, Design and Development.
-
Rina_84 #1
Help in C#
Greetings To aLL!
Hi, I'm Rina here... I neeD ur heLp fr0m U (anY kiNd usErs ouT thEre!) :) I'm
deVeLopinG a perSoNaL WebsiTe and I waNNa uSe C# proGraMMinG. I'm quiTe
famiLiar wiTh thE coDes bUt I aM noT sUre Where t0 pLaCe theM.
1. HoW and WheRe sHd I pLaceD the C# coDes in DreaMweaVer?
2. I've leaRnT to Use ASP.NET to deVeloP a webSiTe and I waNNa knoW wheTher
the CoDes uSed are simiLar?
tHis is b'Coz I'LL pLaced tHe CoDes in aspx.cs in ASP.NET...sO hoW abouT
dReamWeaVer?
eg. of Asp.neT C# coDes R as aTTachedD!
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace MTT
{
/// <summary>
/// Summary description for Service.
/// </summary>
public class Service : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Image services;
protected System.Web.UI.WebControls.ImageButton travel_btn;
protected System.Web.UI.WebControls.Label cFare;
protected System.Web.UI.WebControls.Label aFare;
protected System.Web.UI.WebControls.Label depDate;
protected System.Web.UI.WebControls.Label dest;
protected System.Web.UI.WebControls.Label tripType;
protected System.Web.UI.WebControls.DataList dlSvc;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label lblError;
private void Page_Load(object sender, System.EventArgs e)
{
//string SvcID = Request.QueryString["Svc_Id"];
SqlConnection conn = new SqlConnection();
SqlCommand comm = new SqlCommand();
try
{
conn.ConnectionString = "data source = localhost; initial catalog = db;
integrated security = true;";
conn.Open();
comm.Connection = conn;
comm.CommandText = "select * from Service where Svc_Id like 'IN%' or
Svc_Id like 'MY%' or Svc_Id like 'TH%'";
SqlDataReader dr = comm.ExecuteReader();
dlSvc.DataSource = dr;
dlSvc.DataBind();
dr.Close();
}
catch (SqlException ex)
{
lblError.Text = ex.Message;
}
finally
{
conn.Close();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.travel_btn.Click += new
System.Web.UI.ImageClickEventHandler(this.travel_b tn_Click);
this.dlSvc.SelectedIndexChanged += new
System.EventHandler(this.dlSvc_SelectedIndexChange d);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void dlSvc_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void travel_btn_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
Response.Redirect("TravelInfo.aspx");
}
}
}
Rina_84 Guest



Reply With Quote

