今天费了很大的劲儿才搞定!下面贴出代码和总结:

1.首先是前台代码:

<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="CategoryList.aspx.cs" Inherits="Bridgetree.Admin.CategoryList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script language=javascript> function edit(c_id) {/*此处的c_id为某一控件对象,因为传入的值为this*/ var lb_Edit_ID = c_id.id;/*取控件的id属性值*/
var ids = lb_Edit_ID.substring(lb_Edit_ID.lastIndexOf("_") + 1, lb_Edit_ID.length);/*获取数据库的ID字段*/
var CategoryID = $("span[ID='lbl_CategoryID_" + ids + "']").text();
/*根据id取文本值。
注:
  • text() - 设置或返回所选元素的文本内容(即设置或获取标签内的文本)
  • html() - 设置或返回所选元素的内容(包括 HTML 标记)
  • val() - 设置或返回表单字段的值(即设置或获取控件的文本)
  • 详情点击
*/

            var Category = $("span[ID='lbl_Category_" + ids+ "']").text();
/*alert($("#lbl_Category_" + ids).text());*/
var HourlyCost = $("span[ID='lbl_HourlyCost_" + ids + "']").text();
var BillingRate = $("span[ID='lbl_BillingRate_" + ids + "']").text(); $("#hf_CategoryID").val(CategoryID);/*设置控件的文本*/
$("#tb_Category").val(Category);
$("#tb_HourlyCost").val(HourlyCost);
$("#tb_BillingRate").val(BillingRate); /*var rate = document.getElementById("rate_" + id) rate.readOnly = false;
rate.style.backgroundColor = "white" e = document.getElementById("BtnEdit_" + id)
e.disabled = true; e = document.getElementById("BtnUpd_" + id)
e.disabled = false; rate.focus();*/
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server" ClientIDMode="Static">
<table id="conversionTable" class="tableCommon table-hover" width="100%">
<asp:Repeater ID="rpt_CategoryList" runat="server" OnItemDataBound="rpt_CategoryList_ItemDataBound">
<HeaderTemplate>
<tr>
<th>Category</th>
<th>HourlyCost($)</th>
<th>BillingRate</th>
<th>Edit</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:Label runat="server" ID="lbl_Category" Text='<%#Eval("Category1") %>'></asp:Label><asp:Label runat="server" ID="lbl_CategoryID" style="display:none;" Text='<%#Eval("CategoryID") %>'></asp:Label></td>
<td><asp:Label runat="server" ID="lbl_HourlyCost" Text='<%#Eval("HourlyCost") %>'></asp:Label></td>
<td><asp:Label runat="server" ID="lbl_BillingRate" Text='<%#Eval("BillingRate")%>'></asp:Label></td>
<td>
<asp:LinkButton runat="server" ID="lb_Edit" href="#TB_inline?height=300&width=400&inlineId=myOnPageContent" Class="thickbox" OnClientClick="edit(this);">Edit</asp:LinkButton></td> /*此处需要注意:该标签会先执行onclick事件,然后再去执行href*/
</tr>
</ItemTemplate>
</asp:Repeater> </table>
<div id="myOnPageContent" style="display:none;">
<input type="hidden" id="hf_CategoryID" runat="server"/>
<p>Category:<input id="tb_Category" readonly="true" /></p>
<p>HourlyCost($):<input id="tb_HourlyCost"/></p>
<p>BillingRate($):<input id="tb_BillingRate"/></p>
<asp:Button runat="server" ID="btn_Save" Width="50px" Text="Save" OnClick="btn_Save_Click"/>
</div> </asp:Content>

2.后台代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; namespace Bridgetree.Admin
{
public partial class CategoryList : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.rpt_CategoryList.DataSource = PCS.DAL.EF.Repository.GetInstance().GetCategoryList();
this.rpt_CategoryList.DataBind();
} protected void rpt_CategoryList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)//**
{
Label lbl_CategoryID = e.Item.FindControl("lbl_CategoryID") as Label;
Label lbl_Category = e.Item.FindControl("lbl_Category") as Label;
Label lbl_HourlyCost = e.Item.FindControl("lbl_HourlyCost") as Label;
Label lbl_BillingRate = e.Item.FindControl("lbl_BillingRate") as Label;
LinkButton lb_Edit = e.Item.FindControl("lb_Edit") as LinkButton;
if (lbl_CategoryID != null && lbl_Category != null && lbl_HourlyCost != null && lbl_BillingRate != null && lb_Edit != null)
{
/*此处ID在被解释成静态之后会变成控件的name和id属性,
* 而且嵌套在模板页中的控件会自动添加上<content>的ID值(例如:<input name="ctk100$BodyContent$RealName" id="BodyContent_RealName" />)
* ,若套在模板页中需要在<content>中添加ClientIDMode="Static",这样ID就只对应静态控件的ID属性*/
lbl_CategoryID.ID = "lbl_CategoryID_" + lbl_CategoryID.Text;
lbl_Category.ID = "lbl_Category_" + lbl_CategoryID.Text;
lbl_HourlyCost.ID = "lbl_HourlyCost_" + lbl_CategoryID.Text;
lbl_BillingRate.ID = "lbl_BillingRate_" + lbl_CategoryID.Text;
lb_Edit.ID = "lb_Edit_" + lbl_CategoryID.Text;
//lb_Edit.Attributes.Add("onclientclick", "edit(" + lbl_CategoryID.Text + ")");
}
}
}
}
}

3.最终效果

4.用到的文件:

http://files.cnblogs.com/ethanwill/jquery-tanchucengxiaoguoone.rar

DIV遮罩层传值的更多相关文章

  1. jquery实现div遮罩层

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

  2. div 遮罩层 弹窗

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

  3. JS+CSS简单实现DIV遮罩层显示隐藏【转藏】

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

  4. JS+CSS简单实现DIV遮罩层显示隐藏

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

  5. 在iframe内页面完全加载完后,关闭父页面生成的div遮罩层

    遮罩层div为iframe父页面生成,需在iframe内页面完全加载完后,关闭遮罩层 alertMsgClose() :函数为关闭遮罩层函数 此段代码在iframe页面内: <script> ...

  6. Jquery实现遮罩层,就是弹出DIV周围都灰色不能操作

    <%@ page language="java" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC & ...

  7. 前端小结(3)---- 添加遮罩层,并弹出div

    有如下div: <div id='pop-div' class="pop-box"> <div class="input-group has-info& ...

  8. 点击弹出div内容包括遮罩层

    效果: HTML: <!-- 添加分组按钮 -->             <div class="group_add" onclick = "docu ...

  9. 在HTML中实现和使用遮罩层

    Web页面中使用遮罩层,可防止重复操作,提示loading:也可以模拟弹出模态窗口. 实现思路:一个DIV作为遮罩层,一个DIV显示loading动态GIF图片.在下面的示例代码中,同时展示了如何在i ...

随机推荐

  1. Web程序发布后显示个性化图标

    采用Tomcat发布程序后,浏览器上默认显示程序的图标是Tomcat图标.如下图所示: 需要显示自己个性化的图标,比如,这里显示一个图标. 只需要如下三步设置即可. 将制作的ico图标放在程序的根目录 ...

  2. myeclipse10.0优化

    一.Myeclipse10修改字体  MyEclipse10是基于Eclipse3.7内核,但在Eclipse的Preferences-〉general-〉 Appearance->Colors ...

  3. IIS修改队列长度

    Internet Information Services (IIS) 限制了在任何给定时间可在队列中等待的应用程序池请求的最大数量.如果达到此限制,则所有新请求都将被拒绝,而且用户将收到错误消息“5 ...

  4. Catch Application Exceptions in a Windows Forms Application

    You need to handle the System.Windows.Forms.Application.ThreadException event for Windows Forms. Thi ...

  5. ionic+angulajs

    基于ionic+angulajs的混合开发实现地铁APP 项目源码地址:https://github.com/zhangxy1035/SubwayMap 一.项目简介 在该项目中的地铁app是基于io ...

  6. iOS新上线注意事项

    上传不出现构建版本 现在苹果要求先上传版本,然后在提交审核,但是现在经常上传完应用后,不出现构建版本,等待很久很久,也不出现,那么怎么解决,我告诉你~~尼玛的苹果是自己数据丢包了,结果就造成你不出现构 ...

  7. Elasticsearch强大的聚合功能Facet

    在常规数据库中,我们都知道有一个sql就是group,分组.如果主表只有对应的一个列记录的分组的ID,那么还好统计,比如说每本书book表,有一个分类catId,记录是属于哪一类的书,那么直接按照ca ...

  8. Mongodb FAQ fundamentals(基础篇)

    Mongodb FAQ(基础篇),是官方文档的翻译.如有翻译不到之处,还请谅解. 1.Mongdb是什么数据库? mongodb是一个面向文档(document)的数据库,既不支持表连接,也不支持事务 ...

  9. Almeza MultiSet Pro(批量安装程序) V8.7.6中文特别版

    Almeza MultiSet Pro(批量安装程序)是一款非常实用的工具.它能够帮你批量地安装常用的软件.这将解决每次重装系统后能够快速方便地重装常用软件.使用这款软件不需要编写程序,还可以在安装过 ...

  10. Struts2 web.xml文件配置

    在导入了项目需要使用的核心jar包之后需要在web.xml中配置Struts. 1. Struts2的知识点普及: Struts2共有5类配置文件,分别罗列如下: 1), Web.xml; 在没有使用 ...