Gewgala
asked on
Call C# codebehind in iframe#2 from c# codebehind in iframe#1
Is it possible to call a c# codebehind method in iframe#2 from c# codebehind in iframe#1 and if so, how?
ASKER
Yeah, sorry they're on the same page, so for example, frames.aspx has 2 iframes, testFrame1 and testFrame2. I would like to call from testFrame1 in codebehind a c# codebehind method in testFrame2 and have it do it's thing.
Can you show me how your IFrames are declared in the HTML designer, please?
Bob
Bob
ASKER
This is frames.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frame2.aspx.cs" Inherits="frame2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form2" runat="server">
<iframe id="ImagesFrame" src="frame1.aspx" width="500" height="250"></iframe><br />
<iframe id="replacementFrame" src="frame2.aspx" width="500" height="200"></iframe>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frame2.aspx.cs" Inherits="frame2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form2" runat="server">
<iframe id="ImagesFrame" src="frame1.aspx" width="500" height="250"></iframe><br />
<iframe id="replacementFrame" src="frame2.aspx" width="500" height="200"></iframe>
</form>
</body>
</html>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In order to reference any control in the code-behind, you need the runat="server" attribute:
<iframe id="ImagesFrame" src="frame1.aspx" width="500" height="250" runat="server"></iframe><b r />
<iframe id="replacementFrame" src="frame2.aspx" width="500" height="200" runat="server"></iframe>
Bob
<iframe id="ImagesFrame" src="frame1.aspx" width="500" height="250" runat="server"></iframe><b
<iframe id="replacementFrame" src="frame2.aspx" width="500" height="200" runat="server"></iframe>
Bob
ASKER
Ok, assuming I add in runat="server" (which I forgot to put in the code I posted, sorry about that) how would I go about it then?
Are you trying to access code in frame1.aspx from frame2.aspx?
Bob
Bob
ASKER
In frame1.aspx.cs, I would like to have it that a call is made, on page load (not from a click or mouse over) to a c# codebehind method in frame2.aspx.cs. frame1.aspx is in the first frame, frame2.aspx is in the second frame.
I dont think you can do that, acccessing the code behind of one page from another. If you could let us know what you are trying to achieve, we could help better.
ASKER
well what if I did this... from frame1 I have code that loads a page in frame2, but the url that I specify is one with a variable attached to it, such as frame2.src = "page.aspx?variable=value" and then have the codebehind execute accordingly?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeah, but what's cool is that it works! Thank you for supplying information on how to accomplish this.
Bob