Hi all.

As I'm a newbie and learning VB.NET, I have some questions about pages within pages or maybe even another facit of coding. First, is there a way to call and load an aspx page within another aspx page? Secondly, would this be better accomplished using modules?

Here's a small overview of what I'm trying to do...

In a Request Forms web app, there are systems which have their own request form. From the default page, the user is asked which "system form" they will need. Upon selecting a radio button, the form (each form has different questions) will dynamically display below which the data from the form will be submitted to a SQL db.

Any suggestions? Please include examples if possible.

Thank you.

10 Years
Discussion Span
Last Post by SheSaidImaPregy

First, to include pages inside other pages, use the code below:

<!-- Include Virtual="/filename.ascx" -->

You should always use the ascx extension for include files in asp.net They are unable to be displayed in browser and prevents hacking. It works the same as an aspx file but with an unviewable file when manually typing it's address.

Two ways you can do your radio list. One way is through javascript, the other is through the server. Through javascript, you would use the visibility action and it would be instant on the page without reloading. Downfall of this is that some people do not have javascript enabled, and that the person has to download ALL information on the page, whether or not it is relavent to them.
The other way is through the server. You would place all forms in one runat=server form tag with all elements placed in placeholders with the visibility off except for your radiolist. When a user clicks on the radiolist (and you should have autopostback="true" within your radiolist, it will post back to the server and your coding will do a simple select case or if statement to see which is true. Following which is true, the placeholder
s visibility would be set to true and the next step on the form would be available.

<script  runat="server">
Sub btnSubmit_OnClick(sender As Object, e As EventArgs)
  if radiolist1.SelectedItem.Text = 1 then
    rblChooseForm.Visible = False
   	phForm1.Visible = True
  elseif radiolist1.SelectedItem.Text = 2 then
    rblChooseForm.Visible = False
   	phForm2.Visible = True
  elseif radiolist1.SelectedItem.Text = 3 then
    rblChooseForm.Visible = False
   	phForm3.Visible = True
    rblChooseForm.Visible = True
  end if
End Sub

<form runat="server">
<asp:RadioButtonList OnSelectedIndexChanged="btnSubmit_OnClick" autopostback="true" id="rblChooseForm" runat="server">
  <asp:ListItem Text="Form 1" value="1" />
  <asp:ListItem Text="Form 2" value="2" />
  <asp:ListItem Text="Form 3" value="3" />
<asp:PlaceHolder Visible="false" id="phForm1" runat="server">
      <td>Form 1 here</td>
<asp:PlaceHolder Visible="false" id="phForm2" runat="server">
      <td>Form 2 here</td>
<asp:PlaceHolder Visible="false" id="phForm3" runat="server">
      <td>Form 3 here</td>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.