在做一个企业站,其中招聘信息已经列表显示了,我想点击“查看该职位”,就能弹出一个小的页面,用表格的形式把该职位的详细信息显示出来,小页面不显示地址栏,工具栏,只显示页面中的内容。页面gridview代码如下:
<asp:GridView ID="GVJobs" runat="server" AutoGenerateColumns="False"
Width="698px">
<Columns>
<asp:BoundField DataField="J_jobName" HeaderText="职位名称" />
<asp:BoundField DataField="J_jobNumber" HeaderText="招聘人数" />
<asp:BoundField DataField="J_jobEducation" HeaderText="学历要求" />
<asp:BoundField DataField="J_jobTime" HeaderText="发布时间" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" Text="查看该职位" PostBackUrl='<%# "~/JobsView.aspx?J_jobId=" + Eval("J_jobId") %>'
CausesValidation="False"></asp:LinkButton>
<asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl='<%# "~/Apply.aspx?J_jobId=" + Eval("J_jobId") %>'
CausesValidation="False" Text="应聘该职位"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:GridView ID="GVJobs" runat="server" AutoGenerateColumns="False"
Width="698px">
<Columns>
<asp:BoundField DataField="J_jobName" HeaderText="职位名称" />
<asp:BoundField DataField="J_jobNumber" HeaderText="招聘人数" />
<asp:BoundField DataField="J_jobEducation" HeaderText="学历要求" />
<asp:BoundField DataField="J_jobTime" HeaderText="发布时间" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" Text="查看该职位" PostBackUrl='<%# "~/JobsView.aspx?J_jobId=" + Eval("J_jobId") %>'
CausesValidation="False"></asp:LinkButton>
<asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl='<%# "~/Apply.aspx?J_jobId=" + Eval("J_jobId") %>'
CausesValidation="False" Text="应聘该职位"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
解决方案 »
- asp.net 怎样查询数据库返回一个数据
- 关于变量的问题???????
- 获取webconfig连接字符串,坐等回复
- script和客户端验证控件(在线)
- 急,在线等....Repeater内的动态linkbutton控件问题
- 超难度:---这样的SQL操作怎么实现??(三个字段)
- 郁闷散分!!!
- 请问大家有好的制作图表的控件吗?
- 如何设置IQueryable的类型为函数返回的类型??
- 其他信息: 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke
- url重写网站,删除数据后重新绑定gridview地址又变回真实的了,怎么办
- Access Insert 语法错误!!!!!!!!
CausesValidation="False"></asp:LinkButton>
改为。
<a href="#" onclick="javascript:window.open('改下路径../JobsView.aspx?J_jobId="+<%#Eval("J_jobId")%>+"','','width=430,height=450,scrollbars=1,resizable=0')">查看该职位</a>
loc_x = document.body.scrollLeft + event.clientX - event.offsetX + 100;
loc_y = document.body.scrollTop + event.clientY - event.offsetY + 170;
window.showModalDialog("Default2.aspx", self, "edge:raised;scroll:0;status:0;help:0;resizable:1;dialogWidth:350px;dialogHeight:350px;dialogTop:" + loc_y + "px;dialogLeft:" + loc_x + "px");
}模态窗口。
loc_x = document.body.scrollLeft + event.clientX - event.offsetX + 100;
loc_y = document.body.scrollTop + event.clientY - event.offsetY + 170;
window.showModalDialog("处理页", self, "edge:raised;scroll:0;status:0;help:0;resizable:1;dialogWidth:350px;dialogHeight:350px;dialogTop:" + loc_y + "px;dialogLeft:" + loc_x + "px");
} 在处理页上,进行数据的绑定和处理~~
<script>
function open()
{
window.showmodaldialog('url' 参数....)
}
</script> onclientclik="open()"
div1.innerHtml = 内容
内容在这里可以是一个table的html也可以是文本
<asp:Label ID="lbl_Role" runat="server" Text='<%# Bind("J_jobName") %>' Visible="false"></asp:Label>
并且对于LinkButton1和LinkButton2各加入属性
CommandName="Command1"
CommandName="Command2"然后给GridView加入事件
protected void GVJobs_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton Search= (LinkButton)e.Row.FindControl("LinkButton1");
Search.CommandArgument = e.Row.RowIndex.ToString();
}
} protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
if (e.CommandName == "Command1")
{
string role = ((Label)this.GridView1.Rows[index].FindControl("lbl_Role")).Text;
string url = "RoleManage.aspx?UserID=" + userID + "&type=1";//举例
ClientScript.RegisterStartupScript(this.GetType(), "pop", "popUp('" + url + "' ,600,450)", true);
}
if (e.CommandName == "Command2")
{
string role = ((Label)this.GridView1.Rows[index].FindControl("lbl_Role")).Text;
string url = "RoleManage.aspx?UserID=" + userID + "&type=2";//举例
ClientScript.RegisterStartupScript(this.GetType(), "pop", "popUp('" + url + "' ,600,450)", true);
}
}最后在前台页面加入楼主想要的JS
<script type="text/javascript">
function popUp(url,width,height,winname,left,top)
{
var left = (left==''||left==null)?(screen.width - width)/2:left;
var top = (top==''||top==null)?(screen.height - height)/2:top;
var winnames = (winname=='')?'popUpWin':winname;
window.open(url, winnames, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
</script>
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton Search= (LinkButton)e.Row.FindControl("LinkButton1");
Search.CommandArgument = e.Row.RowIndex.ToString();
LinkButton Apply= (LinkButton)e.Row.FindControl("LinkButton2");
Apply.CommandArgument = e.Row.RowIndex.ToString();
}
}
刚才少了一句
{
if (e.Row.RowType == DataControlRowType.DataRow)
{ ((HyperLink)e.Row.Cells[0].FindControl("HyperLink1")).Attributes.Add("onclick", "windows.open('')");
((HyperLink)e.Row.Cells[0].Controls[0]).Attributes.Add("onclick", "windows.open('')");
}
}