简体   繁体   English

如何在iframe中显示aspx网站

[英]how to show the aspx site in the Iframe

I have a Button1 on the firstpage.aspx page and by Button1click I call a webservice in the codebehind which passes me a random number. 我在firstpage.aspx页上有一个Button1,通过Button1click我在后面的代码中调用了一个Web服务,该服务向我传递了一个随机数。

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim test As localhost.servicetest = New localhost.servicetest

    Dim answer as string =test.randomnumber().tostring
End Sub

I have another aspx form secondpage.aspx which only consists of label, which I want to pass the answer variable from the webservice. 我有另一个aspx形式secondpage.aspx,它仅包含标签,我希望从web服务传递答案变量。

I added javascript to the firstpage.aspx which creates an iframe with secondpage.aspx 我在firstpage.aspx中添加了javascript,该脚本使用secondpage.aspx创建了一个iframe

(function () {
    $('#Button1').click(function () {
        $('<iframe />', {
            name: 'frame',
            id: 'frame',
            src:'secondpage.aspx'
        }).appendTo('body');
    });
    return false;
});

My first problem is that this way I dont know how to load the variable into the secondpage.aspx before I display them in the iframe. 我的第一个问题是,以这种方式,我不知道如何在iframe中显示变量之前将其加载到secondpage.aspx中。

Who do I do it? 我该怎么做? Do I really need to take the java code way or can I do all the things in the code behind? 我真的需要采用Java代码方式还是可以做后面代码中的所有事情?

My goal is to create an iframe with a "new instance" of secondpage.aspx with a new random number at every Buttonclick. 我的目标是在每个Buttonclick上创建一个带有secondpage.aspx“新实例”的iframe,并为其添加一个新的随机数。

I hope you guys can help 希望大家能帮忙

Cheers Steven 干杯史蒂文

You can use a Session variable (Session[name]) and define a variable on your secondpage to store this value. 您可以使用Session变量(Session [name])并在第二页上定义一个变量来存储此值。

On the first page : "Dim answer as string =test.randomnumber().tostring" You have to store answer in the Session and call it in the secondPage 在第一页上:“将答案作为字符串= test.randomnumber()。tostring”必须将答案存储在会话中,然后在第二页中调用它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM