首 页 网络编程
网页制作 图形图象 操作系统 冲浪宝典
软件教学 认证考试

网络安全 网络办公 行业资讯 评测对比
您当前位置:站长天空 -> 网页制作-> HTML教程
ajax实现网易相册样式的修改_ajax教程
作者:网友供稿 点击:0
推荐
西部数码-全国虚拟主机10强!20余项虚拟主机管理功能,全国领先!第6代双线路虚拟主机,南北访问畅通无阻!可在线rar解压,自动数据恢复设置虚拟目录等.免费赠送访问统计,企业邮局.Cn域名注册10元/年,自助建站480元起,免费试用7天,满意再付款!P4主机租用799元/月.月付免压金
站内搜索
文章页数:[1] 

普通的ajax应用,结合javascript对html元素的动态操控,结合而成一个优美的效果。

还是用Ajax.net,设置与前篇文章一样,不再累述。
代码如下:
163photoTest.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class _163photoTest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        description.Text  = GetDescription();
        AjaxPro.Utility.RegisterTypeForAjax(typeof(_163photoTest));
    }

    //取数据库里的描述
    protected string GetDescription()
    {
        try
        {
            string strComm = "select  photo_description from tab_photo where photo_id=1";
            SqlConnection myConn = new SqlConnection("user id=sa;password=123;Database =test;data source=z;");
            myConn.Open();
            SqlCommand myComm = new SqlCommand(strComm, myConn);
            SqlDataReader myReader = myComm.ExecuteReader();
            myReader.Read();
            return myReader.GetString(0);
        }
        catch
        {
            return "";
        }
    }

    [AjaxPro.AjaxMethod]
    //将description保存进数据库 www.knowsky.com
    public bool UpdateDesc(string description)
    {
        try
        {
            string strComm = "update tab_photo set photo_description=" + description + " where photo_id=1";
            SqlConnection myConn = new SqlConnection("user id=sa;password=123;Database =test;data source=z;");
            myConn.Open();
            SqlCommand myComm = new SqlCommand(strComm, myConn);
            myComm.ExecuteNonQuery();
            return true;
        }
        catch
        {
            return false;
        }
    }
}

163photoTest.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="163photoTest.aspx.cs" Inherits="_163photoTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
<script language="javascript" type="text/javascript">
    function display()
    {
        document.getElementById(descfield).style.display=block;
        document.getElementById(descfield).value = document.getElementById(description).innerText ;
        document.getElementById(description).style.display=none;
        document.getElementById(save).style.display=block;
    }
    var s;
    function UpdateDesc()
    {
        s= document.getElementById("descfield").value;
        document.getElementById("descfield").value="正在保存";
        _163photoTest.UpdateDesc(s,UpdateDesc_callback);
    }
   
    function UpdateDesc_callback(res)
    {
        if (res)
        {
            document.getElementById(description).style.display=block;
            document.getElementById("description").innerText =s;
            document.getElementById(descfield).style.display=none;
            document.getElementById(save).style.display=none;
        }
    }
</script>
</head>
<body onload="document.getElementById(descfield).style.display=none;document.getElementById(save).style.display=none;">
    <form id="form1" runat="server">
    <div id="div1" onmousemove="this.style.backgroundColor=#C0C0FF;" onmouseout="this.style.backgroundColor=;" onclick="display()">
        <asp:Label ID="description" runat="server" Text="Label"></asp:Label>

    </div>
    <input type="text" id ="descfield"  />
        <input type="button" id="update" value="修改描述"  onclick="display()"/>
        <input type="button" id="save" value="保存修改"  onclick="UpdateDesc()"/>
        <br />
    </form>
</body>
</html>

出处:Coder at the Doorsill——风中聆听 BLOG


文章整理:站长天空 网址:http://www.z6688.com/
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

文章页数:[1] 


放大字体显示 缩小字体显示 打印文章 推荐给朋友
热门文章
·C#时间函数扩展-.NET教程,C#语言
·成人影片女明星jameson推出手机情色铃声服务
·窗体中控件自动随窗体变化大小-.NET教程,组件控件开发
·C#使用CDO发送邮件-.NET教程,C#语言
·浅析nat的类型
·我的字符和文件加密类,128位加密-.NET教程,评论及其它
·数字机顶盒技术综述 (一)
·数字多媒体广播平台及其关键技术
·java 线程安全-JSP教程,Java技巧及代码
·Remoting和Web服务的区别-.NET教程,Web Service开发
最新文章
·如何通过博客月赚几万美金?_网赚技巧
·浅析广告联盟与个人网站的盈利_网赚技巧
·google adsense会议的主要内容回顾_网赚技巧
·赵克:创业基本素质勤奋专业低调务实_站长访谈
·行业网站分析之一:行业网站现状与前景_站长心得
·分享:做网站月入7000的网站赚钱经验_站长心得
·首页所应该达到的几个目标(2)_站长心得
·google sandbox效应_google推广
·google旧瓶装新酒 用遗弃技术开发web新应用_google推广
·认识google优化排名_google推广
相关主题
  • ajax实现分页查询_ajax教程
  • ajax实现不刷屏的前提下实现页面定时刷新_ajax教程
  • ajax实现datagrid/datalist动态tooltip _ajax教程
  • ajax实现在textbox中输入内容,动态从数据库中模糊查询显示到下拉框中_ajax教程
  • ajax实现无刷新树_ajax教程
  • 西部数码虚拟主机

    友情链接
    CNNIC 西部数码
    万网 自助建站
    虚拟主机 asp空间
    域名注册 域名
    域名申请 主页空间
    论坛空间 网站空间
    国际域名 虚拟空间
    空间租用 DDOS防火墙
    成都主机托管 四川主机托管
    主机租用 服务器租用
    网站目录 自助建站
    虚拟主机 网址大全
    软件下载
    自助链接
    虚拟主机资讯 特价虚拟主机
    版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
    关于我们:站长天空:专业提供最新的站长资讯、在线教程、虚拟主机权威评测、虚拟主机性能对比、网站制作教程,开发教程,站长工具。包括网页制作教程、冲浪宝典、编程参考、操作系统、软件教学、行业动态等。
    特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。
    发表评论 打印  刷新     关闭