webform怎么弹出一个webform2,并通过填写webform2的textbox,点击按钮把textbox的值返回webform的Label控件?

nnlyc 2004-08-16 09:25:46
因为webform要上传图片,有encType="multipart/form-data"内容,无法直接通过webform上的textbox控件更新数据库,想通过如题方法更新。
1、点击webform的linkbutton,怎么弹出webform2?
2、webform2点击按钮返回textbox值的同时更新数据库,如何使webform跟着刷新页面?

C#,最好能给段代码,谢谢!
...全文
204 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
exee 2004-08-17
  • 打赏
  • 举报
回复
在第二个页面中写入<HEAD>
<SCRIPT LANGUAGE="JScript">
function ref()
{
window.opener.location.reload();
}
</SCRIPT>
</HEAD>
exee 2004-08-17
  • 打赏
  • 举报
回复
如果用window.open函数打开的对话框在第二个web页中使用window.opener.location.reload();这句来刷新第一个web页
exee 2004-08-17
  • 打赏
  • 举报
回复
http://dotnet.aspx.cc/ShowDetail.aspx?id=49ML4AO8-5PB3-4KNY-NJZD-LJOIOXV4M1X4
这有答案!!!
不过这是VB.net的可自己改成C#
cjzlxy 2004-08-17
  • 打赏
  • 举报
回复
up
zyc2 2004-08-17
  • 打赏
  • 举报
回复
form1:
button1 click事件:
string script = "<script> window.open('form2.aspx');</script>";
Response.Write(scritp);

form2:
javascript:
function popup()
{
window.opener.document.all["form1中textbox的id"].Value=document.all["form2中textbox的id"].Value;
window.close();
}
nnlyc 2004-08-17
  • 打赏
  • 举报
回复
先试试goody9807()的例子:)
谢谢大家
nnlyc 2004-08-17
  • 打赏
  • 举报
回复
有没有c#后台的代码啊,我对js不熟:(
goody9807 2004-08-17
  • 打赏
  • 举报
回复
给你个例子

WebForm2.aspx.vb
Inherits System.Web.UI.Page
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add("onclick", "var st=window.showModalDialog('user.aspx?val='+document.all('TextBox1').value);document.all('TextBox1').value=st;return st;")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
RegisterStartupScript("key", "<script>window.opener=null;window.close(this);</script>")
End Sub
user.aspx.vb
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents cancel As System.Web.UI.WebControls.Button
Protected WithEvents ok As System.Web.UI.WebControls.Button
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim str As String
If Not IsPostBack Then
str = Request.QueryString("val")
TextBox1.Text = str
End If
End Sub
Private Sub cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancel.Click
RegisterStartupScript("key", "<script>window.returnValue='null';window.opener=null;window.close(this);</script>")
End Sub
Private Sub ok_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ok.Click
RegisterStartupScript("key", "<script>window.returnValue=document.all('TextBox2').value;window.opener=null;window.close(this);</script>")
End Sub
goody9807 2004-08-17
  • 打赏
  • 举报
回复
关于模态窗口(showModalDialog)的专题讨论!
1.模态窗口的打开
2.模态窗口的关闭
3.模态窗口的传递参数。
4.其他。。。。


1.window.showModalDialog("DialogPage.aspx","newwin","dialogHeight: 200px; dialogWidth: 150px; dialogTop: 458px; dialogLeft: 166px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;");

2.window.close();

3.传值
ParentPage.aspx:
window.showModalDialog("DialogPage.aspx?para1=aaa¶2=bbb");

DialogPage.aspx:
string str1=Request.QueryString["para1"].toString();
string str2=Request.QueryString["para2"].toString();

返回值
DialogPage.aspx:
window.returnValue="aaa";

ParentPage.aspx:
var str=window.showModalDialog("DialogPage.aspx");

4.
aspx页面在showmodeldialog情况下为什么一提交就重新打开一个页面?
showmodaldialog打开的页面中在<head></head>之间加入一行:<base target="_self">




zhn0410 2004-08-17
  • 打赏
  • 举报
回复
学习。
morality 2004-08-17
  • 打赏
  • 举报
回复
用 javascript 实现,即 用 showModalDialog() 函数来实现!代码如下:

<HTML>
<HEAD>


<script language="JavaScript">
function showSelectUserDialog(ctl) {
var strRetVal = window.showModalDialog("dialog.aspx", "", "dialogWidth:450px; dialogHeight:400px; center:yes; resizable:yes; status:no")
if (strRetVal != null) {
ctl.value = strRetVal
}
}

</script>
</HEAD>
<body>
<table width="90%" align="center">

<tr>
<td align="right" width="100">接收者:</td>
<td>
<p><font face="宋体" color="#3300ff">
<input type=text name=txtUser id=txtUser width="300px" size="20" >
<a href="#" onclick="showSelectUserDialog(txtUser)">选择...</a>
</p>
</FONT>
</td>
</tr>

</table>

</body>
</HTML>


//--------dialog.aspx中的相应脚本函数--------

<script>
// 单击“确定”按钮
function btnOK_Click() {
window.returnValue = document.forms[0].textbox1.value
self.close()
}

// 单击“取消”按钮
function btnCancel_Click() {
self.close()
}
</script>

黄金安魂曲 2004-08-17
  • 打赏
  • 举报
回复
http://dotnet.aspx.cc/ShowDetail.aspx?id=49ML4AO8-5PB3-4KNY-NJZD-LJOIOXV4M1X4
「已注销」 2004-08-17
  • 打赏
  • 举报
回复
用js实现
xiaopai20 2004-08-16
  • 打赏
  • 举报
回复
用javascript比较容易实现~
aquariusdeng 2004-08-16
  • 打赏
  • 举报
回复
1.弹出WebForm2:
string scripts = "<script>var win=window.open(Webform2.aspx?time=" + DateTime.Now.ToString() + "','Webform2' ,'height=200, width=800, top=100, left=5,toolbar=no, menubar=no, resizable=no, scrollbars=no,location=no, status=yes'); \r\n win.focus();</script>";
Response.Write (scripts);
2.刷新WebForm1
Response.Write("<script>window.close();window.opener.document.forms[0].submit();</script>");
张海霖 2004-08-16
  • 打赏
  • 举报
回复
看了半天,就是传值的问题,与c#没关系
a=showModelDialog("1.htm");


window.returnvalue="xxxx";

62,072

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧