C#相关知识
来源:互联网 发布:js往json中添加元素 编辑:程序博客网 时间:2024/05/22 17:59
1、style
.style1
{
text-align: center;
font-size: xx-large;
color:Blue;
background-color: #A0FFFF;
width: 80%;
margin-left: 10%;
height:650px;
}
2、调用别的模块,比如说登录模块
<uc1:enter ID="enter1" runat="server" />
<div style=" width:100%; height:30px;background-color:#F0F8FF; ">段子</div>
<br /> 空行
3、datalist
<asp:DataList ID="DataList1" runat="server" Width="100%" BorderWidth="0px">
<ItemTemplate> //模板
<div style=" width:20px; text-align:center; height:120px; float:left;" ><p><%# DataBinder.Eval(Container.DataItem, "id")%> </p></div> //数据绑定
<div style="width:110px;height:120px; float:left"
<p align="center">
<asp:Image id="Image1" Width="100" Height="100" runat="server" ImageUrl='<%# "../Default.aspx?ImgID="+ DataBinder.Eval(Container,"DataItem.id")%>'>
</asp:Image>
<%# DataBinder.Eval(Container.DataItem, "id")%>
</p>
</div>
<div style="width:110px;height:120px; float:left">
<a >
<asp:Image id="Image2" Width="30" Height="30" runat="server" ImageUrl='<%# "../Default.aspx?ImgID="+ DataBinder.Eval(Container,"DataItem.id")%>'>
</asp:Image>
<%# DataBinder.Eval(Container.DataItem, "id")%>
</a>
</div>
</div>
<div style="width:40px;height:120px; float:right">
<div style=" height:40; width:40px;background-color:#F5F5F5"></div>
<div style=" height:40; width:40px;background-color:#F5F5F5"></div>
<div style=" height:40; width:40px;background-color:#F5F5F5"></div>
</div>
</ItemTemplate>
</asp:DataList>
4、连接数据库的类
public class db
{
public static string connstring =
//@"data source=WIN7-20140423SZ\SQLEXPRESS; Initial Catalog=user_login;integrated security=SSPI";
@"server=qds148466258.my3w.com;user id=qds148466258;password=huzhenghui119; Initial Catalog=qds148466258_db";
// @"Data Source=.\SQLEXPRESS;Initial Catalog=WEBSQL;Integrated Security=SSPI";
public static void DoSql(string sql)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = connstring;
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
public static DataSet GreatDs(string sql)
{
SqlConnection myconn = new SqlConnection(connstring.ToString());
myconn.Open();
SqlDataAdapter mydr = new SqlDataAdapter(sql, myconn);
DataSet myds = new DataSet();
mydr.Fill(myds);
myconn.Close();
return myds;
}
public void MsgBox(string strMsg, string URL)
{
string StrScript;
StrScript = ("<script language=javascript>");
StrScript += ("alert('" + strMsg + "');");
StrScript += ("window.location='" + URL + "';");
StrScript += ("</script>");
System.Web.HttpContext.Current.Response.Write(StrScript);
}
5、数据绑定的后台
public partial class ups_china : System.Web.UI.Page
{
private int CID;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CDataBind();
}
}
private void CDataBind()
{
int provice=1,city=1,company=1;
SqlConnection conn = new SqlConnection(db.connstring.ToString());
conn.Open();
string mysql1 = "select * from UPSData where(provice='"+ provice+"' and city='"+city+"' and company='"+company+"')";
SqlDataAdapter sa = new SqlDataAdapter(mysql1, conn);
DataSet ds = new DataSet();
sa.Fill(ds, "table1");
//处理
DataTable dtNew = ds.Tables["table1"].Copy(); //复制dt表数据结构
dtNew.Clear(); //清除数据
foreach (DataRow mydr in ds.Tables["table1"].Rows)
{
dtNew.Rows.Add(mydr.ItemArray);
//dtNew.Rows.Add(ds.Tables["table1"].Rows[i].ItemArray);
}
/*
for (int i = 0; i < dtNew.Rows.Count; i++)
{
dtNew.Rows[i]["id"] = i + 1;
}
*/
//绑定数据
System.Web.UI.WebControls.PagedDataSource ps = new PagedDataSource();
ps.DataSource = dtNew.DefaultView;
ps.AllowPaging = true;
ps.PageSize = 5;
//ps.CurrentPageIndex = curPage - 1;
this.DataList1.DataSource = ps;
this.DataList1.DataBind();
conn.Close();
//绑定完毕
//处理图片
}
}
6、脚本
<script type="text/javascript">
function fatie() {
document.getElementById("ft").style.backgroundColor = '#00ff0f';
document.getElementById("nan").onclick = function () { boy() };
<a onclick="NeatDialog()">显示</a>
7、登录界面后台
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect("register.aspx");
}
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "" || TextBox2.Text == "")
{
Response.Write("<script>aleret('用户名或密码为空');</script>");
}
else if(TextBox3.Text!=Session["vcode"].ToString())
{
Response.Write("<script>alert('验证码输入错误');</script>");
}
else
{
string pu, pw;
pu = TextBox1.Text.Replace("'", "''");
pw = TextBox2.Text.Replace("'", "''");
string sql = "select * from userinfo where usertext='" + pu + "' and userpass='" + pw + "'";
DataTable dt = new DataTable();
dt = db.GreatDs(sql).Tables[0];
if (dt.Rows.Count > 0)
{
Response.Write("<script>alert('您已登录成功');</script>");
Session["memberlogin"] = "ok";
Session["membername"] = pu;
Session["memberpass"] = pw;
Response.Redirect("zhuye.aspx");
}
else
{
Response.Write("<script language=javascript>alert('用户名或者密码错误!');</script>");
}
}
}
- C#打印相关知识
- C#接口相关知识
- C#相关知识
- 一些C#相关知识整理
- C#反射相关知识学习
- C#路径设置相关知识
- c#类的相关知识
- C#中数组的相关知识
- C#中字符串转换的相关知识
- C#多线程和socket的相关知识
- C#下的winform编程相关知识
- C# 委托delegate的相关知识
- C#开发 WinForm中窗体传值相关知识
- C#和VB.NET类型相关知识汇总
- C#操作Word生成索引相关知识整理
- C#控件之进度条—progressBar及其相关知识
- C#中DataGridView相关知识技术指导QQ:595789813
- C# 多线程、异步线程、线程池相关知识
- Android Api Demos登顶之路(三十九)Fragment-->show hide
- java(08-19)
- iOS开发页面之间的几种传值方式
- R语言_基本图形
- 从一个取值范围为1~N的不重复数列中找出所有满足两数和为N+1的数对
- C#相关知识
- 8-19
- Git flow的分支模型与及常用命令简介
- hdu4252单调栈
- 转:java中include动作和include指令的区别
- 作为软件开发人员应该知道的最基本的东西
- DB2 substr,instr使用
- 在MyEclipse的web项目/java项目中,使用Hibernate-tools中的hbm2java和hbm2ddl工具,根据hbm文件自动生成pojo和数据库脚本
- 我在写多语言支持时用到的东西