Use jquery to dynamically create an IFRAME, embed pages, and pass parameters to an embedded page in a blank Web page

Source: Internet
Author: User

[CSharp] View plaincopyprint?
Using Microsoft.VisualBasic;
Using System;
Using System.Collections;
Using System.Collections.Generic;
Using System.Data;
Using System.Diagnostics;
Using System.Collections.Specialized;
Using Microsoft.JScript;
Namespace MCS
{
public partial class MyDialog:System.Web.UI.Page
{
protected string strparam = null;
private void Page_Load (System.Object sender, System.EventArgs e)
{

}

public string GetParam ()
{
Strparam = string. Empty;
int LOOP1 = 0;
int loop2 = 0;
string[] arr1 = null;
string[] arr2 = null;
NameValueCollection coll = null;

Load Form variables into NameValueCollection variable.
coll = request.querystring;
Get Names of all keys into a string array.
arr1 = Coll. AllKeys;
for (LOOP1 = 0; Loop1 <= arr1. GetUpperBound (0); loop1++)
{
Strparam = Strparam + ARR1[LOOP1] + "=";
Get all values under the This key.
ARR2 = Coll. GetValues (LOOP1);
for (loop2 = 0; loop2 <= arr2. GetUpperBound (0); loop2++)
{
if (Information.isdate (ARR2[LOOP2]))
ARR2[LOOP2] = DateTime.Parse (Arr2[loop2]). ToString ("mm/dd/yyyy hh:mm:ss tt");

Strparam = Strparam + Arr2[loop2] + "&";
}
}

if (strparam.length > 0 && strparam.contains ("&"))
Strparam = Strparam.trimend (' & ');
return strparam;
}

public string GetPage ()
{
return request.querystring["page"];
}
}
}
The above GetPage method gets the page embedded in the IFRAME, the GetParam method is to get the parameters to be passed
Here is the front desk jquery page
[CSharp] View plaincopyprint?
<%@ page language= "C #" autoeventwireup= "true" codebehind= "MyDialog.aspx.cs" inherits= "MCS. Mydialog "%>

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>Dialog</title>
<script src= "Scripts/jquery-1.4.1.min.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" language= "JavaScript" >
$ (document). Ready (function () {
var if_w = $ ("Body"). width ();
var if_h = $ (window). Height ();
$ ("<iframe width=" + if_w + "' height= '" + if_h + "' id= ' Frame1 ' ></iframe>"). Prependto (' body ');
$ ("#Frame1"). attr ("src", "<%= getpage ()%>" + "?" + unescape ("<%= getparam ()%>"));
});
</script>
<body>
</body>
As to why it should be placed in an IFRAME, instead of using the Load method directly, to prevent a new page from popping up when jumping, instead of jumping on this page

Use jquery to dynamically create an IFRAME, embed pages, and pass parameters to an embedded page in a blank Web page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.