以上就是js的代码,弹出窗口是利用jquery的弹出层,弹出层中嵌套iframe,iframe中利用upimg.aspx上传页面,各人假如有其他需要可以本身去设计弹出结果。为了各人调试利便,我将我实现弹出层的代码贴出来。
弹出层结果利用的是popup_layer.js方案,需要进一步加工的伴侣可以本身在百度中谷歌。ele6为弹出引发需要的层,blk6为弹出层主体,close6为层中承载封锁按钮的层。代码如下
<div id="ele6" style="cursor:hand; color: blue; display:none;"></div><div id="blk6" class="blk" style="display:none;">
<div class="head"><div class="head-right"></div></div>
<div class="main">
<a href="javascript:void(0)" id="close6" class="closeBtn"></a>
<iframe src="upimg.aspx"></iframe>
</div>
</div>
别健忘引用jquery和popup_layer.js。
5、upimg.aspx页面
aspx代码
<div><asp:FileUpload ID="FU_indexIMG" runat="server" />
<br />
<asp:Button ID="Button1" runat="server" Text="上传" onclick="Button1_Click" />
<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="打消" />
</div>
对应的cs代码
protected void Button1_Click(object sender, EventArgs e){
string imgdir = UpImg();
script = "window.parent.upimg('" + imgdir + "');";
ResponseScript(script);
}
protected void Button2_Click(object sender, EventArgs e)
{
string script = "window.parent.close();";
ResponseScript(script);
}
/// <summary>
/// 输出剧本
/// </summary>
public void ResponseScript(string script)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder("<script language='javascript' type='text/javascript'>");
sb.Append(script);
sb.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(), RandomString(1), sb.ToString());
}
/// <summary>
/// 得到随机数
/// </summary>
/// <param name="count">长度</param>
/// <returns></returns>
public static string RandomString(int count)
{
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
byte[] data = new byte[count];
rng.GetBytes(data);
return BitConverter.ToString(data).Replace("-", "");
}