asp.net弹出一个层对话框

fym_wlll 2012-03-12 02:38:17


如上图所示,我想实现:点击复制 模板列(ItemTemplate)时,弹出一个 div层对话框,

在这个对话框里,得到当前行的id值,然后根据此id值,在数据库中插入一条新的记录。

请教 这个功能如何实现,用jquery或其它的js弹出对话框都行。

谢谢。
...全文
183 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjqm113 2012-05-19
  • 打赏
  • 举报
回复
楼主用什么方式解决了,能分享一下吗?我也在做这方面的问题。
fym_wlll 2012-03-13
  • 打赏
  • 举报
回复
新问题出来了!

我虽然实现了打开模态窗口,在模态窗口里面的表单提交时,得不到两个下拉列表框的值。



如上图所示,
按下确定时,得不到dropdownlist2和dropdownlist1里的值。真晕。


无爱大叔 2012-03-13
  • 打赏
  • 举报
回复
artdialog?
SomethingJack 2012-03-13
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 fym_wlll 的回复:]

非常感谢各位,我用showmodaldialog完成了,在360浏览器下测试,也是模态窗口,
并且可以将父窗口的值传过来:

C# code


protected void gvNewsList_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == Data……
[/Quote]
我的分- -
fym_wlll 2012-03-13
  • 打赏
  • 举报
回复
非常感谢各位,我用showmodaldialog完成了,在360浏览器下测试,也是模态窗口,
并且可以将父窗口的值传过来:



protected void gvNewsList_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
{
((LinkButton)e.Row.Cells[4].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除:" + e.Row.Cells[0].Text.Trim() + "第" + e.Row.Cells[1].Text.Trim() + "年,第" + e.Row.Cells[2].Text.Trim() + "个季度的上报信息吗?')");

//第5列加上一个弹出模态窗口showModalDialog('left.aspx?type={0}',window,'dialogHeight:330px; dialogWidth: 500px;dialogTop:px; dialogLeft:px; edge: Raised; center: Yes; help: No; resizable: No; status: No;scroll:No','alwaysRaised= yes')
((LinkButton)e.Row.Cells[5].Controls[0]).Attributes.Add("onclick", "javascript:return showModalDialog('bfzxcopy.aspx?sbji=" + e.Row.Cells[2].Text.Trim() + "&sbyear=" + e.Row.Cells[1].Text.Trim() + "',window,'dialogHeight:330px; dialogWidth: 500px;dialogTop:px; dialogLeft:px; edge: Raised; center: Yes; help: No; resizable: No; status: No;scroll:No','alwaysRaised= yes') ");


}
}


}

fym_wlll 2012-03-13
  • 打赏
  • 举报
回复
结贴。不用这个showmodaldialog了,换另一种方法了。
Jdragon 2012-03-13
  • 打赏
  • 举报
回复
送分的
ycproc 2012-03-13
  • 打赏
  • 举报
回复

Page.RegisterStartScript("<script>alert('提示框');</script>"); 
fym_wlll 2012-03-13
  • 打赏
  • 举报
回复
我的代码是:
.aspx代码:

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

<!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>将指定季度copy为新的季度:</title>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
width: 24px;
}
</style>
<base target ="_self" />
</head>
<body>
<form id="form1" runat="server" action="">
<div>

<table class="style1">
<tr>
<td class="style2">
 </td>
<td>
您确定想将:<asp:Label ID="Label1" runat="server" Text="Label"
style="color: #0000FF; font-weight: 700"></asp:Label>
,<asp:Label ID="Label2" runat="server" Text="Label"
style="color: #0000FF; font-weight: 700"></asp:Label>
年,第<asp:Label ID="Label3" runat="server" Text="Label"
style="color: #0000FF; font-weight: 700"></asp:Label>
季度的数据复制到下述季度吗?</td>
</tr>
<tr>
<td class="style2">
 </td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="DropDownList1" ErrorMessage="请选择年度" InitialValue="请选择年度"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style2">
 </td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="DropDownList2" ErrorMessage="请选择季度" InitialValue="请选择季度"></asp:RequiredFieldValidator>
<br />
</td>
</tr>
<tr>
<td class="style2">
 </td>
<td>
<asp:Button ID="Button1" runat="server" Text="确定" onclick="Button1_Click" />
   
<asp:Button ID="Button2" runat="server" Text="取消" onclick="Button2_Click" />




</td>
</tr>
<tr>
<td class="style2">
 </td>
<td>
 </td>
</tr>
</table>

</div>
</form>
</body>
</html>



.cs代码:


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Data.SqlClient;


public partial class Manage_bfzxcopy : System.Web.UI.Page
{


//modify by wll 2012 3.13
CommonClass CC = new CommonClass();

protected void Page_Load(object sender, EventArgs e)
{

//if (!IsPostBack)
//{
if (Session["nameyh"] == null && Session["pwdyh"] == null) //
{
Response.Redirect("Login.aspx"); //将页面重新定向到登录页面中
}
//}

Label1.Text = Session["nameyh"].ToString();
Label2.Text = Request.QueryString["sbyear"].ToString();
Label3.Text = Request.QueryString["sbji"].ToString();

//====2
DateTime tnow = DateTime.Now;//现在时间
ArrayList AlYear, yesYear;
AlYear = new ArrayList();
yesYear = new ArrayList();

int j;
for (j = 2011; j <= 2016; j++)
AlYear.Add(j);

//====3 季度是 1 2 3 4共计四个季度
ArrayList AlMonth;
AlMonth = new ArrayList();
for (j = 1; j <= 4; j++)
AlMonth.Add(j);
//====4
DropDownList1.DataSource = AlYear;
DropDownList1.DataBind();//DropDownList1绑定年
//DropDownList1选择当前年
DropDownList1.SelectedValue = tnow.Year.ToString();

DropDownList1.Items.Insert(0, new ListItem("请选择年度", "请选择年度"));


DropDownList2.DataSource = AlMonth;
DropDownList2.DataBind();//DropDownList2绑定季


DropDownList2.Items.Insert(0, new ListItem("请选择季度", "请选择季度"));


}

protected void Button2_Click(object sender, EventArgs e)
{
Response.Write(" <script >window.close(); </script > ");
}





protected void Button1_Click(object sender, EventArgs e)
{





string str_sbdwname = this.Label1.Text.Trim(); //单位名称

string str_sbyear = this.DropDownList1.SelectedValue.ToString().Trim(); //年

string str_sbji = this.DropDownList2.SelectedValue.ToString().Trim(); //季




string SqlStr = "select * from tb_sb where sbdwname='" + str_sbdwname + "' and sbyear='" + str_sbyear + "' and sbji='" + str_sbji + "'";

Response.Write(""+ SqlStr +"");
SqlConnection con = CC.GetConnection();
con.Open();//打开数据库连接
SqlCommand amd = new SqlCommand(SqlStr, con);

SqlDataReader dr = amd.ExecuteReader();
if (dr.Read()) //如果有数据,则显示 此数据已有!
{
//yesYear.Add(dr["sbyear"].ToString());//
//Response.Write(CC.MessageBox("" + dr["sbyear"].ToString() + ""));
//sDescription.InnerHtml = "注意," + dr["sbyear"].ToString() + "年,第" + dr["sbji"].ToString() + "季度的数据您已上报!请选择别的年度和季度。";

Response.Write(CC.MessageBox("恭喜!页。"));

}
else
{
//sDescription.InnerHtml = "";

Response.Write(CC.MessageBox("恭喜!" + str_sbji + "2页。"));

Response.Write(""+ str_sbji+"");

}
dr.Close();
con.Close();
}
}

  • 打赏
  • 举报
回复
one page!!
xiaoyuan402 2012-03-12
  • 打赏
  • 举报
回复


遮罩层样式
.black_overlay
{
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color:Gray;
z-index: 1001;
-moz-opacity: 0.6;
opacity: .80;
filter: alpha(opacity=50);
}

<script language="javascript" type="text/javascript">
function ShowDiv() {
G('showDiv').style.display = 'block';
G('fade').style.display = 'block';
G('fade').style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + 'px';
}
function CloseDiv() {
G('showDiv').style.display = 'none';
G('fade').style.display = 'none'
}
function CheckForm() {
if (G("txtDepName").value.replace(/\s/g, "") == "") {
alert("名称不能为空!");
G("txtDepName").focus();
return false;
}
return true;
}
</script>


+++++++++++++++++++++++++++++++

<a href="javascript:ShowDiv();"><img src="../images/add.gif" border="0" />添加部门</a>
遮罩层
<div id="fade" class="black_overlay"></div>
弹出层
<div id="showDiv" style="width: 500px; display:none">
<table width="500px" cellpadding="0" cellspacing="0">
<tr>
<td colspan="4">
<p class="title2">
<span>部门信息</span><img src="../images/close.jpg" onclick="CloseDiv();" alt="关闭" width="14"
height="14" /></p>
</td>
</tr>
<tr>
<td align="right">
<font color='red'>*</font>名称:
</td>
<td align="left">
<asp:TextBox runat="server" ID="txtDepName"></asp:TextBox>
</td>
<td align="right">
上级单位
</td>
<td align="left">
<asp:DropDownList runat="server" ID="dlDep" DataTextField="DepName" DataValueField="DepID">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right">
简称:
</td>
<td align="left">
<asp:TextBox runat="server" ID="txtJC"></asp:TextBox>
</td>
<td align="right">
排序号:
</td>
<td align="left">
<asp:TextBox runat="server" ID="txtPX" Width="50px" onKeyPress="OnlyDouble(this.value);"
Text="0"> </asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
禁用:
</td>
<td align="left">
<asp:CheckBox runat="server" ID="chkIsNotUse" Text=""></asp:CheckBox>
</td>
</tr>
<tr>
<td align="center" colspan="4">
<p class="WBbg">
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="imgSave_Click" OnClientClick="return CheckForm();">
<img src="../images/save.gif" border="0" onclick="return CheckForm();"/>保存</asp:LinkButton>
</p>
</td>
</tr>
</table>
</div>
fym_wlll 2012-03-12
  • 打赏
  • 举报
回复
我用window.open,但360浏览器,在新的页面打开。这样不好。
naonaoye 2012-03-12
  • 打赏
  • 举报
回复
ClientScript.RegisterStartupScript(this.GetType(), "aa", "<script>window.showModalDialog('页面地址?id=3','dialogWidth:400px;dialogHeight:400px')</script>");
大概就这样






----------------------------------签----------名----------栏----------------------------------
终于可以出差了
bdmh 2012-03-12
  • 打赏
  • 举报
回复
window.open已经足够满足你了
SomethingJack 2012-03-12
  • 打赏
  • 举报
回复
使用window.open或者window.showdilog...不一定非要用层摄- -
非要用的话 Jquary插件也很多的

62,071

社区成员

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

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

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

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