views:

466

answers:

3

I have very little experience with ASP.NET and I am doing some self-training before I start writing my first web site/application, which will be a calibration utility. How that utility works is not my concern right now. However, the utility eventually needs to end up embedded in someone else's web site, either just as a URL to the page with my code, or embedded (say, as an HTML frame or an iframe). To figure out the basics of this, I coded up two very simple ASP.NET web sites, a "parent" which contains the frameset, and a "child" which I am trying to put into one of the frames.

The parent's "Default.aspx" HTML code is basically this:

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head runat="server">
    <title>Parent Site Test 1</title>
</head>

<frameset cols="300,*">
    <frame name="outer" src="parent.aspx" noresize></frame>
    <frame name="inner" src="[what do I put here?]"</frame>
</frameset>

</html>

The "parent.aspx" page has only the most basic HTML in it:

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        I am the parent web form.
    </div>
    </form>
</body>
</html>

The child web site (as I have it now) lives in a separate VS2008 solution, for the purposes of this exercise, because I am trying to reproduce the conditions in which someone else's web site has to reference my calibration web page/site/thing. I was originally thinking there would be some way to package the entire child into a single DLL, and then there would be some way to tell the parent to use that DLL as the source for the child frame. This comes from my experience in the Java world - using JBoss and J2EE, this would be easily solved because the child would just be deployed as another EAR file.

Being completely inexperienced with VS2008 and ASP.NET, I spent quite a few hours on Google over the past few days trying to find an answer, to no avail.

  • Is what I'm trying to do reasonable; is it the right way to think about solving the problem?

  • Can I deploy the child as a fairly independent and self-contained web site (or web application... I'm still unclear on the differences) by somehow packaging it into a single DLL? If yes, then how do I actually create this DLL from my web site/application in VS2008, and how do I then reference it in the parent web site?

  • If I am totally off track here, how can I create this parent/child combination in some other way? The child (really, the calibration utility I will eventually write) does need to be in ASP.NET (with C#) but I don't have any control over the parent site, since it's someone else's code, and they just want to be able to drop in my utility.

Thanks for the help! The more specific you can be, the better. I am very new to ASP.NET and Visual Studio, though I do have plenty of experience programming in other languages and IDEs.

+1  A: 

If you know the client also uses ASP.Net, you could build it as a User Control.

Joel Coehoorn
+1  A: 

If you have IIS6 or higher, you can run both of the web applications and in your src="[what goes here]" you put the local URL of the child website (maybe http://localhost/ChildTestWebsite/child.aspx). Then when you load up http://localhost/ParentTestWebsite/Default.aspx you should see the frames.

To package it into a single DLL, I believe you have to make it just a user control like Joel said, otherwise you have the DLL + aspx pages.

s_hewitt
When I have the DLL + aspx files, what is in the DLL? Is it all the codebehind stuff? E.g. if I have Default.aspx, then would Default.aspx.cs end up inside the DLL?
Matt Ball
Yes.You will have the DLL files + aspx files + ascx files along with configs etc. All of the code behinds will be in the DLL.
s_hewitt
+1  A: 

What you should do depends on how the interaction between the parent and child is.

If the parent is not going to access any server-side functionality on the child, you can just reference to the absolute http path in the src on the frame tag. You might get security issues in some browsers if you try to access javascript methods and the 2 apps are on diferent web servers, but this is not .NET specific.

If the parent is going to access server side functionality, you need to provide the server side components somewhere in the parent project. This is more complex. I think you have to build all child pages as web controls that is included in a parent aspx page.

1: Build the child project as a webcontrol library of server controls that can be used by the parent. This is best approach conserning deployment. Everything is built into one single dll. The biggest disadvantage to this, is that server controls can only be developed in code. You have no visual designer to help you.

2: Create a Web Application project. In VS2008 you do this by "New Project" and then find the "ASP.NET Web Application" template. This means a web project where all code behind (everything inside the cs files) is build into a single dll. In this scenario, you create user controls (ascx files) that can be used by the parent page. The disanvantage of this is that user controls must be loacted on the runnin web app, so you must copy all ascx files to the deployed location of the parent web site. The dll must also be copied to a bin folder in the parent web site. Here you have the advantage that it is much simpler to design the GUI in VisualStudio. Designing the gui and code behind for ascx user controls are very similar to creating full aspx web pages.

awe