I'm trying to generate a page with HTML sent via parameter, but I have no idea how to do it.
For exemple: I'm creating the whole HTML code on the page 'page1.aspx' and I want to show this content on another page, 'page2.aspx', preferably in another tab.
Is there a way to do this?
I'd like not to create a new aspx file everytime I do this, rather, use the same page2.aspx file and just replace the content dynamically.
Related
From the code on one page I want to be able to generate an instance of another page and parse the html from certain controls on that page.
this is what i have tried so far
var APIListPage = (APIList)BuildManager.CreateInstanceFromVirtualPath("~/APIHelp/APIList.aspx", typeof(APIList));
ParseHtml(APIListPage.pdfPage);
The problem is APIListPage.pdfPage is always null.
You must call the page instance's "ProcessRequest" procedure, to let it experience a full Page LifeCycle. It won't load just by creating the instance.
I am generating HTML in the Page Load method in more than 1 page.
All those generated HTML are the same across all pages.
I found that it's a pain to have the same codes in every page because once I need to change something, I need to change them in all pages.
Example:
I have a div in each of those page:
<div id="Questions" runat="server"></div>
In the Page Load method of each page, I generate the same HTML.
Questions.InnerHTML = "<span>...etc...</span>";
So I decided to make a page that generates those contents, then load this page inside the div of the other pages, means, if I ever need to change, I only change this page.
I created a Handler, Questions.ashx. This handler generates that HTML and sends back a response.
Now to include it, I know I can use JQUERY's .load() function, but I would like to generate those HTML from server side.
What I've tried:
Questions.InnerHTML = LoadControl("~/Handlers/Questions.ashx").ToString();
But I received this error:
Type 'Questions' does not inherit from 'System.Web.UI.UserControl'.
"LoadControl" is for "User Controls", not HTTP Handlers..
You will probably be better off creating a User Control, which is an .ascx file. This can contain HTML, ASPX controls and code behind, and can be referenced by any ASPX page.
More Info here:
http://msdn.microsoft.com/en-us/library/y6wb1a0e(v=vs.100).aspx
I have a .html.
I also have a .aspx that have two panels. I want to display my .html page between the panels, how can I do that?
I would like my .aspx page to end up with following structure. If I just drag the .html file in, it only creates a hyperlink. Should I put the .html code into a asp web forms instead?
...
<asp.Panel ...>
</asp.Panel>
.html
<asp.Panel ...>
</asp.Panel>
...
If you want it in the same page, you could just paste the contents of the html body between your panels.
If your html is going to change in future, and you want it to remain a different page, use an iframe and set it to display your html page.
If you want to combine both on the fly, you can use a asp.net Literal control, read the contents of your html page and set the contents of the html to the Text property of Literal
You can use iframe to display html page.
Use like this:
<iframe width="100%" height="100%" src="a.html" />
Convert your html page as user controls. Then include that user controls in aspx page.
Details:
1. Create a user control. ( .ascs extention file ).
2. Place html code inside user control.
3. Create asp page.
4. Include user control in asp page via following code.
<%# Register src="control.ascx" tagname="controlName" tagprefix="pre" %>
<pre:controlName ID="controlId" runat="server" />
I am trying to display a page into an IFrame.
The IFrame is displayed into a fancyBox overlay popup.
I have a list with the http links (gets compiled at runtime and it constantly changes).
Using a global variable I can access the list with the links.
But the http link in the list must match the link I have clicked.
If I can even get the link which I have clicked it will also be enough (the link brings up a fancyBox popup so it doesn't actually bring up a new page so to speak)
How to do that?
You have to write some tricky code to achieve this, main goal is to edit the dynamically added page content by adding wrapper tag (with onclick event) around all the links, writing javascript to be called using that wrapper to findout which link has been clicked,
You can try this by doing following steps
1) Get the content of IFrame , using the following JQuery code you can get the content of IFrame
var $currentIFrame = $('#myIFrame');
var content = $currentIFrame.contents();
2) Now manupulate these content by finding all the links inside that page and wrapping them with a tag that should have onclick event e.g. span , you have to write some javascript function to fire on a link if user clicks it.
see the following link for how to manipulate content
Get all links inside iframe and add blank target attribute
I've got a master page and a content page. How can I add controls to the master page's content placeholders programmatically?
Try something like following:
this.Master.Controls.FindControl("ContentPlaceHolderID").Controls.Add(yourControl);
this.Page.Master.FindControl
As said above would work fine.
Alternatively, make whatever placeholder in your master page a ContentPlaceHolder, and then your child pages can put stuff there directly without having to go up through the Master page.