<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RefTopicList.aspx.cs" Inherits="Project.RefTopicList" %>

<!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>
<base target="_self" />
<script src="../jquery/jquery-1.8.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
function Change(SCHeckBox, curHidOID) {
var objs = document.getElementsByTagName("input");
for (var i = ; i < objs.length; i++) {
if (objs[i].type.toLowerCase() == "checkbox")
objs[i].checked = false;
}
var SelectCheckBoxID = SCHeckBox.id;
document.getElementById(SelectCheckBoxID).checked = true;
$("#hidenOIDValue").val(curHidOID); }
function GetHidValue() { if ($("#hidenOIDValue").val() != "") {
returnValue = $("#hidenOIDValue").val();
window.close();
}
else {
alert('至少选择一项');
} }
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="" cellspacing="" cellpadding="">
<tr>
<td class="tb_td_content">
<asp:Button ID="QueryWatch" runat="server" Text="&nbsp;&nbsp;查&nbsp;询&nbsp;&nbsp;" OnClick="QueryWatch_Click" />&nbsp;
<input id="btnSure" type="button" value="&nbsp;&nbsp;确&nbsp;定&nbsp;&nbsp;"
onclick="GetHidValue();" />
</td>
</tr>
</table>
</div>
<div id="DivGridview">
<asp:GridView ID="CtrlGrid" runat="server" Width="80%" AllowSorting="True" CellPadding=""
BorderWidth="1px" BorderStyle="Solid" AutoGenerateColumns="False" OnRowDataBound="CtrlGrid_RowDataBound"
PageSize="" Height="128px">
<Columns>
<asp:TemplateField HeaderText="选择">
<ItemTemplate>
<asp:HiddenField runat="server" ID="hidenCheckOID" Value='<%#Eval("ID") %>' />
<asp:CheckBox runat="server" ID="chkSelect" />
</ItemTemplate>
<HeaderStyle Wrap="False" Width="60px" HorizontalAlign="Center" />
<ItemStyle Wrap="false" Width="60px" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="名称">
<ItemTemplate>
<asp:Label ID="lblTopicName" runat="server" Text='<%# Eval("NAME")%>'></asp:Label>
</ItemTemplate>
<HeaderStyle Wrap="false" Width="100px" HorizontalAlign="Center" />
<ItemStyle Wrap="false" Width="150px" HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<asp:HiddenField ID="hidenOIDValue" runat="server" />
</form>
</body>
</html>

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

<!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 id="Head1" runat="server">    

<title></title>     

<link href="../../Themes/Default/control.css" rel="stylesheet" type="text/css" />     

<link href="../../Themes/Default/ui.css" rel="stylesheet" type="text/css" />    

<script src="../../Scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>   

  <script src="../../Scripts/jquery/jquery-1.8.0.min.js" type="text/javascript"></script>     

<script src="../../Scripts/Validate/ControlValidate.js" type="text/javascript"></script>    

<link href="../../Themes/Default/controlvalidate.css" rel="stylesheet" type="text/css" /> 

    <script type="text/javascript">     

    $(document).ready(function () {          

      var typevalue=<%=base.GetParaValue("type") %>;          //后台传值判断是添加还是编辑             

//0代表是编辑,页面上的选择按钮隐藏      

if (typevalue == "")       

         {             

    $("#btnSelect").hide();              

   }                        

else{          

//单击选择按钮弹出要选择的信息,选中之后在该页面获取该信息

      $("#btnSelect").click(function () {               

       var oidd = window.showModalDialog('RefTopicList.aspx',"", 'dialogWidth=900px;dialogHeight=650px;help=no;location=no;scroll=no;resizable=no');         

             if (oidd != undefined && oidd != "") {                                

              GetTopicJson(oidd);          //调用处理程序的方法,用json解析获取数据        

    }                  });            

  }          

     });        

  function GetTopicJson(oid) {          

    $.ajax({             

     type: "post",            

      url: "HandlerRefTipic.ashx?OID="+oid ,                

  dataType: "json",                

  success: function (data) 

{                      

      $("#txtprojectName").val(data[].TOPIC_NAME);                             

               },                

  error: function (XMLHttpRequest, textStatus, errorThrown) {   alert(errorThrown);    }  

  });        

  }

    </script>

</head>

<body>    

<form id="form1" runat="server">

<div class="datagrid_search_div">
<table class="tb" border="" cellpadding="" cellspacing="">
<tr>
<td class="tb_td_title">
项目名称:
</td>
<td class="tb_td_content" colspan="" valign="top">
&nbsp;<asp:TextBox ID="txtprojectName" runat="server" Width="500px" request="true"
MaxLength="" CssClass="txtbox" ToolTip="项目名称,最多100个字符!"></asp:TextBox>
<input id="btnSelect" type="button" value="&nbsp;&nbsp;选&nbsp;择&nbsp;&nbsp;" class="btn_long" />
</td>
</tr> <tr>
<td colspan="" class="tb_td_content" style="text-align: center;">
<asp:Button ID="btnSave" runat="server" class="btn_long" Text="&nbsp;&nbsp;保&nbsp;存&nbsp;&nbsp;"
OnClick="btnSave_Click" />&nbsp;
<input id="btnReset" type="button" value="&nbsp;&nbsp;重&nbsp;置&nbsp;&nbsp;" class="btn_long"
runat="server" onclick="javascript:document.forms[0].reset();" />&nbsp;
<asp:Label ID="TipInfo" runat="server" ForeColor="Red" Font-Bold="True"></asp:Label>
</td>
</tr>
</table>
</div> </body>
</html>

页面前台

<%@ WebHandler Language="C#" Class="HandlerRefTipic" %>

using System;
using System.Web;
public class HandlerRefTipic : IHttpHandler { public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "application/Json";
context.Response.Clear();
context.Response.Write(GetTopicToJson(context.Request["OID"]));
context.Response.Flush();
context.Response.End(); }
/// <summary>
/// 根据标识得到课题对象实体转换成json格式输出
/// </summary>
/// <param name="oid"></param>
/// <returns></returns>
public string GetTopicToJson(string oid)
{
if(string.IsNullOrEmpty(oid))
{
return "";
}
TopicInfoObj obj = new TopicInfoRepository().GetTopicInfoObj(oid);
string str=new ConvertToJson().EntityToJson(obj);
return str; }
public bool IsReusable {
get {
return false;
}
} }

json解析获取数据

 protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
PageGridBind(); }
}
protected void CtrlGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
HiddenField hidenCheckID = (HiddenField)e.Row.FindControl("hidenCheckOID");
CheckBox checkBox = e.Row.FindControl("chkSelect") as CheckBox;
checkBox.Attributes.Add("onclick", "Change(" + checkBox.ClientID + ",'" + hidenCheckID.Value + "')");
base.ChangeRowColor(e);
}
catch (Exception ex)
{ throw ex;
}
}
protected void PageGridBind()
{
GridView view = (GridView)this.FindControl("CtrlGrid");
if (view != null)
{
//DataTable dt=huoqushuju();
view.DataSource = dt;
view.DataBind();
}
}
}

最上面的页面后台代码

上面的js有的是我自己的样式文件,没有上传还有日历js都没有,大概就是这个思路,在第一个页面点击按钮然后弹出框,选中gridview中checkbox的,只能选择一行数据,获取到这行数据的id然后把这行数据通过json解析,然后再传到父级页面,给父级页面的控件赋值,就是这样一个思路,可以评论,吐槽,多多指正,谢谢!

页面单击按钮弹出modaldialog然后调用ajax处理程序获取数据,给父级页面控件赋值的更多相关文章

  1. ExtJS003单击按钮弹出window

    html部分 <input type="button" id="btn" name="name" value="点击&quo ...

  2. asp.net html 单击按钮弹出下拉框效果

    1.说明 需要引用jquery.js文件,我的页面是在asp.net MVC4 添加的web窗体,其他不多说 直接看代码 2.代码 <%@ Page Language="C#" ...

  3. Java实现文件上传-按钮弹出上传页面

    转自: https://blessht.iteye.com/blog/1405057 最近自己在做一个小系统玩的时候涉及到了文件的上传,于是在网上找到Java上传文件的方案,最后确定使用common- ...

  4. 请写出一段JavaScript代码,要求页面有一个按钮,点击按钮弹出确认框。程序可以判断出用

    请写出一段JavaScript代码,要求页面有一个按钮,点击按钮弹出确认框.程序可以判断出用 户点击的是“确认”还是“取消”. 解答: <HTML> <HEAD> <TI ...

  5. Menubutton按钮弹出菜单

    #按钮弹出菜单 from tkinter import * root =Tk() def callback(): print('我被调用了') m = Menubutton(root,text = ' ...

  6. 移动端和PC端页面常用的弹出层

    我们在页面的时候,很多时候用到了弹出层,消息提醒,确认框等等,统一样式的弹出框可以使页面更加优美.在此,我整理一下我们项目的移动端和PC端页面常用的弹出层. 一.移动端 我们需在页面引入弹出框的样式和 ...

  7. jquery点击按钮弹出图片

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  8. fancybox 关闭弹出窗口 parent.$.fancybox.close(); 无反应 fancybox 关闭弹出窗口父页面自动刷新,弹出子窗口前后事件

    当我们在父页面使用 fancybox 弹出窗口后,如果想自己手动关闭,则可以 function Cancel() { parent.$.fancybox.close(); } 如果关闭没有反应,最好看 ...

  9. ExtJs 4.2.1 点击按钮弹出表单的窗口

    初学ExtJs,做项目的时候想做一个这样的效果:点击按钮弹出对话框,之前一直是使用EasyUi来做的, EasyUi里有Dialog,用起来很方便,但是现在转移到ExtJs上后,发现没有Dialog这 ...

随机推荐

  1. C#文件操作 File(静态类)

      操作某一个文件/文件夹,需要一个文件的完整路径 一.使用File的静态方法进行文件操作 1 2 3 4 5 6 7 8 9 //使用file的静态方法进行复制             File.C ...

  2. the license has been canceled

    ideal 的 注册码并没有失效,却显示这个信息 the license has been canceled 如果用的是Windows系统,在hosts文件添加下边的ip及映射 0.0.0.0 acc ...

  3. 【iOS】The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods install

    从 github 下载的项目经常会遇到这个问题, 如图所示: 参考: iOS 'The sandbox is not sync with the Podfile.lock'问题解决 尚未解决…………

  4. 【Android】Mac Android adb 配置

    打开终端,输入下面命令: touch .bash_profile open -e .bash_profile 即新建 “.bash_profile” 文件,并会弹出 “.bash_profile” 文 ...

  5. 从动态代理到Spring AOP(中)

    一.前言 上一章节主要介绍了JDK动态代理和CGLIB动态代理:https://www.cnblogs.com/GrimMjx/p/11194283.html 这一章主要结合我们之前学习的动态代理的基 ...

  6. Python 与数据库交互

    安装:pip3 install pymysql 引入模块在python3里:from pymysql import * 使用步骤:1.创建Connection对象,用于建立与数据库的连接,创建对象调用 ...

  7. Go中的命名规范

    1.命名规范 1.1 Go是一门区分大小写的语言. 命名规则涉及变量.常量.全局函数.结构.接口.方法等的命名. Go语言从语法层面进行了以下限定:任何需要对外暴露的名字必须以大写字母开头,不需要对外 ...

  8. HTML/CSS:block,inline和inline-block概念和区别

    总体概念 block和inline这两个概念是简略的说法,完整确切的说应该是 block-level elements (块级元素) 和 inline elements (内联元素).block元素通 ...

  9. Spring Boot 支持 Https 有那么难吗?

    https 现在已经越来越普及了,特别是做一些小程序或者公众号开发的时候,https 基本上都是刚需了. 不过一个 https 证书还是挺费钱的,个人开发者可以在各个云服务提供商那里申请一个免费的证书 ...

  10. Spring 核心技术(6)

    接上篇:Spring 核心技术(5) version 5.1.8.RELEASE 1.5 Bean 作用域 创建 bean 定义时,你创建了一种用于创建 bean 定义中定义的类实例的方法.bean定 ...