当前位置: 首页 > news >正文

弹出窗口中修改值数据后,父窗口中加载修改后的数据

父窗口中前台代码:

<% ... @PageLanguage="C#"AutoEventWireup="true"CodeFile="testwebpart.aspx.cs"Inherits="wss_testwebpart" %>

<! DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//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" > ...

vargetreturnvalue=null;

functionshowModelWindow()
...{
vara=(screen.height-400)/2;
varb=(screen.width-500)/2;
varshowvalue=window.showModalDialog('xwwtest.aspx','newwindow','dialogWidth:700px;scroll:no;dialogHeight:550px,top='+a+',left='+b+',toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no');

if(showvalue!=null)
...{
document.getElementById(
"Hidden1").value=showvalue;
getreturnvalue
=showvalue;
document.getElementById(
"Button1").onclick=buttonClick();
}

}


functionbuttonClick()
...{
document.form1.submit();
}

</ script >

</ head >
< body >
< form id ="form1" runat ="server" >
< div >
< a href ="#" onclick ="showModelWindow()" > 测试 </ a >
< br />
< br />
< br />
< br />
gfdgfdgdfgdfgfdgfdsgdsgfdsgdgfds
< br />
< br />
< br />
< input id ="Button1" name ="btntest" type ="button" value ="button" onclick ="buttonClick()" />
< asp:Button ID ="Button2" runat ="server" Text ="Button" />< br />
< br />
< asp:GridView ID ="GridView1" runat ="server" AllowPaging ="True" AutoGenerateColumns ="False"
DataSourceID
="SqlDataSource1" OnPageIndexChanging ="GridView1_PageIndexChanging"
PageSize
="4" >
< Columns >
< asp:BoundField DataField ="id" HeaderText ="id" InsertVisible ="False" ReadOnly ="True"
SortExpression
="id" />
< asp:BoundField DataField ="name" HeaderText ="name" SortExpression ="name" />
< asp:BoundField DataField ="subject" HeaderText ="subject" SortExpression ="subject" />
< asp:BoundField DataField ="Source" HeaderText ="Source" SortExpression ="Source" />
</ Columns >
</ asp:GridView >
< input id ="Hidden1" name ="hiddenvalue" type ="hidden" runat ="server" />
< input id ="Text1" type ="text" />< br />
< asp:SqlDataSource ID ="SqlDataSource1" runat ="server" ConnectionString ="DataSource=XWW;InitialCatalog=Testdb;UserID=sa;Password=admin"
ProviderName
="System.Data.SqlClient" SelectCommand ="SELECT*FROM[Test]" ></ asp:SqlDataSource >
< input id ="Button3" type ="button" value ="button" onclick ="getvalue()" />
< asp:Button ID ="Button4" runat ="server" OnClick ="Button4_Click" Text ="Button" />
</ div >
</ form >
</ body >
</ html >

父窗口中后台代码:

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;

public partial class wss_testwebpart:System.Web.UI.Page
... {
protectedvoidPage_Load(objectsender,EventArgse)
...{
if(Request.Form["Hidden1"]!=null)
...{
this.GridView1.DataSourceID="SqlDataSource1";
this.GridView1.DataBind();
}

}

protectedvoidGridView1_PageIndexChanging(objectsender,GridViewPageEventArgse)
...{
this.GridView1.PageIndex=e.NewPageIndex;

Response.Write(e.NewPageIndex.ToString());
this.GridView1.DataBind();

}

protectedvoidButton4_Click(objectsender,EventArgse)
...{
Response.Write(Request.Form[
"Hidden1"].ToString());
}

}

子窗口中前台代码:

<% ... @PageLanguage="C#"AutoEventWireup="true"CodeFile="xwwtest.aspx.cs"Inherits="wss_xwwtest" %>

<! DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//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 language ="javascript" type ="text/javascript" > ...
functionreturnvalue()
...{
window.returnValue
=true;
window.close();
}

</ script >
</ head >
< body >
< form id ="form1" runat ="server" >
< div >
< asp:Button ID ="Button1" runat ="server" OnClick ="Button1_Click" Text ="返回" />< br />
< br />
< input id ="Button2" type ="button" value ="返回值" onclick ="returnvalue()" />
< asp:TextBox ID ="TextBox1" runat ="server" ></ asp:TextBox >
< asp:TextBox ID ="TextBox2" runat ="server" ></ asp:TextBox >
< asp:TextBox ID ="TextBox3" runat ="server" ></ asp:TextBox ></ div >
</ form >
</ body >
</ html >

子窗口中后台代码:

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 wss_xwwtest:System.Web.UI.Page
... {
protectedvoidPage_Load(objectsender,EventArgse)
...{

}

protectedvoidButton1_Click(objectsender,EventArgse)
...{
inti=0;
SqlConnectioncon
=newSqlConnection("server=xww;database=testdb;uid=sa;pwd=admin");
con.Open();
stringcmdtxt="UPDATEtestSETname='"+this.TextBox2.Text+"',subject='"+this.TextBox3.Text+"'whereid="+this.TextBox1.Text.Trim()+"";
SqlCommandcom
=newSqlCommand(cmdtxt,con);
i
=com.ExecuteNonQuery();

if(i!=0)
...{
Response.Write(
"<scriptlanguage='javascript'>alert('修改成功!');window.returnValue='ceshi';window.close();</script>");
//Session["IsGood"]="1";
}

else
...{
Response.Write(
"<scriptlanguage='javascript'>alert('修改失败!')</script>");
}

}

}

在修改一条数据时,为了使弹出的页面及时地得到最新数据,应该清空弹出页面中缓存,所以还应该在页面中添加以下代码,使页面不存在缓存.限制页面读取本地缓存

< META HTTP-EQUIV

相关文章:

  • makefile查找文件是否含某特定字符,若没有才添加;
  • makefile查找文件是否存在,不存在才拷贝;
  • 企业财务报表的分析方法(The analysis of financial statements)
  • c/c++经典面试题
  • 分形艺术 ---- 忘却记忆
  • char和unsigned char--数据类型区别
  • 一个电脑**和黑客的对话(笑死你)
  • Python使用Glob查找文件
  • 关于struts2
  • python 3.8 yolov5 烟火检测配置
  • Simple iptables
  • Yolov4烟火检测
  • Qt5AxContainerd.lib error LNK2019 无法解析的外部符号
  • 光线追踪
  • vscode批量格式化代码
  • CSS魔法堂:Absolute Positioning就这个样
  • ES6系统学习----从Apollo Client看解构赋值
  • GitUp, 你不可错过的秀外慧中的git工具
  • java 多线程基础, 我觉得还是有必要看看的
  • Java教程_软件开发基础
  • Magento 1.x 中文订单打印乱码
  • mysql 5.6 原生Online DDL解析
  • Spring Security中异常上抛机制及对于转型处理的一些感悟
  • vue-cli在webpack的配置文件探究
  • 计算机常识 - 收藏集 - 掘金
  • 微信小程序:实现悬浮返回和分享按钮
  • 学习笔记TF060:图像语音结合,看图说话
  • ionic异常记录
  • 蚂蚁金服CTO程立:真正的技术革命才刚刚开始
  • ()、[]、{}、(())、[[]]命令替换
  • (pytorch进阶之路)CLIP模型 实现图像多模态检索任务
  • (react踩过的坑)Antd Select(设置了labelInValue)在FormItem中initialValue的问题
  • (Redis使用系列) Springboot 实现Redis消息的订阅与分布 四
  • (八)Flask之app.route装饰器函数的参数
  • (接口自动化)Python3操作MySQL数据库
  • (论文阅读32/100)Flowing convnets for human pose estimation in videos
  • (一)Mocha源码阅读: 项目结构及命令行启动
  • (转)linux自定义开机启动服务和chkconfig使用方法
  • (转)使用VMware vSphere标准交换机设置网络连接
  • (转载)利用webkit抓取动态网页和链接
  • .NET CORE Aws S3 使用
  • .net php 通信,flash与asp/php/asp.net通信的方法
  • .NET 中让 Task 支持带超时的异步等待
  • .NET/ASP.NETMVC 大型站点架构设计—迁移Model元数据设置项(自定义元数据提供程序)...
  • .net程序集学习心得
  • .net快速开发框架源码分享
  • .NET连接MongoDB数据库实例教程
  • @WebService和@WebMethod注解的用法
  • [Apio2012]dispatching 左偏树
  • [BZOJ 4129]Haruna’s Breakfast(树上带修改莫队)
  • [BZOJ] 1001: [BeiJing2006]狼抓兔子
  • [C++] cout、wcout无法正常输出中文字符问题的深入调查(1):各种编译器测试
  • [docker]docker网络-直接路由模式
  • [leetcode] Longest Palindromic Substring
  • [linux] git lfs install 安装lfs