简体   繁体   English

如何将服务器端属性值传递给与ASPX页面一起加载到框架中的其他htm页面

[英]How to pass a server side property value to other htm page loaded in frame withing aspx page

In a web application, I have a default.aspx page and have a button at top and shown below: 在Web应用程序中,我有一个default.aspx页面,并在顶部有一个按钮,如下所示: 在此处输入图片说明

When I click the Button-1, a frame is loaded in my page containing two other frames in a frameset. 当我单击Button-1时,一个框架被加载到我的页面中,该框架在框架集中包含另外两个框架。 Each frame in frameset loads a htm page. 框架集中的每个框架都加载一个htm页面。 You can see this as below: 您可以看到以下内容: 在此处输入图片说明

So, hierarchy is as below: 因此,层次结构如下:

  1. Loaded Default.aspx Page 加载的Default.aspx页面
  2. Click on Button-1 单击按钮-1
  3. A Frame is loaded in body of default.aspx which hides the previous contents and display newly loaded frame contents. 一个框架加载在default.aspx主体中,该框架隐藏先前的内容并显示新加载的框架内容。
  4. Newly loaded frame contains a frameset in Default.htm page 新加载的框架在Default.htm页面中包含框架集
  5. Loaded frameset have two frames, first load Header.htm and second loads Contents.htm 加载的框架集有两个框架,第一个加载Header.htm,第二个加载Contents.htm

What I need to do, I want to set the value of Button-2 in Header.htm and that value is assigned to a javascript variable on Default.aspx load. 我需要做的是,我想在Header.htm中设置Button-2的值,并将该值分配给Default.aspx加载时的javascript变量。

I try this var sJSButton2Value = '<%=sButton2Title %>'; 我尝试这个var sJSButton2Value = '<%=sButton2Title %>'; sButton2Title comes from server side script depending upon user language. sButton2Title来自服务器端脚本,具体取决于用户语言。

How, can I pass this to Header.htm from Default.aspx ? 如何将其从Default.aspx传递给Header.htm?
I want to set Button-2 value which is coming from Default.aspx page. 我想设置来自Default.aspx页的Button-2值。
How It can be accomplished ? 如何实现?

You can set the variable in Default.aspx from an iframe like this: 您可以像这样通过iframe在Default.aspx中设置变量:

From inside the iframe: 从iframe内部:

window.parent.SomeFunctionDefinedInDefaultAspx(valueToSet);

This is typically how you would access the "parent" (Default.aspx) of the iframe 通常,这就是您访问iframe的“父级”(Default.aspx)的方式

f you need the button text to be set in the iframe from Default.aspx, you can do that via querystring in the url your specify for the iframe 如果您需要在Default.aspx的iframe中设置按钮文本,则可以通过为iframe指定的网址中的querystring来实现

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

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