Load a second ASP.NET page into codebehind [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have something I'd like to attempt, but am unsure of the best path to accomplish it. I have a page, say default.aspx, that creates some content. I also have a second page, say input.aspx, that creates a small select box. This box is to be loaded via ajax on a chang emade on default.aspx. However, I also need this box to initial load in the codebehind of default.aspx.
Example:
1. default.aspx codebehind creates content and loads input.aspx in the codebehind
2. field changes on default.aspx and input.aspx is changed via ajax using Jquery
However, I cannot seem to find the best possible way to load a second ASP.NET page into the codebehind of the initial page. I was considering using an HttpWebRequest object, but am not sure the syntax. Any help would be appreciated.
Thanks!
At Request of #Mbeckish
What I need to happen is outlined below step-by-step
default.aspx loads with content generated from codebehind
Also in codebehind, a select box is loaded (I have this in a separate input.aspx file now. This is the step I need help with.)
default.aspx response is returned and displayed on client
user changes a form value on default.aspx
the select provided by input.aspx is reloaded from server (I currently use a JQuery ajax request to allow this)

Sounds like your second page 'input.aspx' should really be a UserControl (.ascx file), which you dynamically load (using Page.LoadControl(...)) in your default.aspx page.

What you need is to add an iframe to default1.aspx and set it's src property to be the other page
<iframe src="otherPage.aspx"></iframe>
http://www.w3schools.com/tags/tag_iframe.asp

Related

How can i have a pages text change based on the button clicked on the previous page in c#? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
So i have a Pricing Table with 3 options, all on Upgrade.aspx.
'Starter'
'Champ'
'Master'
There is a button for each option. They will all navigate to Payment.aspx, but i want some variables, such as cost, and plan name, to be different based on what button they clicked on the previous page.
So if they clicked 'Starter' button, the Payment.aspx page would say Starter. But if they clicked the 'Champ' button, the Payment.aspx page would say Champ.
There are a lot of different ways you could do this. It seems a little ambiguous what would work best for your situation however.
One option is to create a singleton class with a variable which you set via button handles (IE sets the variable to "Starter" if that button was pressed).
Then the view for the Payment.aspx page could pull the information from the singleton class or consume it however you want it to.
You could also use form data, cookies, databases, and a variety of other things. It depends on where you want to store the data and how is easiest for you to store it.
There are a ton of facilities for this kind of event handling. I'd recommend looking at this article and see how it works for you MSDN - Cross-Page Posting in ASP.NET Web forms

reading div after javascript load [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm having problems parsing information from a forum.
Heres some examples:
Easy
Hard
It would be really easy to get the information as they are displayed in the div where id = "poe-popup-container".
The problem is that that div is only populated when the browser allows you to see the information. That can be easily reproduced by making your browser height really small and looking in the HTML code for the . However, the div will be empty, but as soon you scroll down to see the item it will change.
I'm trying to read the nodes inside the with htmlagillitypack. The problem is that, as i explained, it only has information when the browser says that you need that information.
So, when you try to download the html, the div is empty.
I've tried to download the page with the web browser too, but the same thing happens.
I'm trying to use the following code:
string page = System.Text.Encoding.UTF8.GetString(Webclient.DownloadData("http://www.pathofexile.com/forum/view-thread/966384"));
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(page);
HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[#id='poe-popup-container']");
MessageBox.Show(node.InnerHtml);
You're trying to do impossible. Javascript is executed in browser. HtmlAgilityPack is library just for parsing static html - it can't execute javascript.
So why don't you look into browser automation instead ? Try for example http://watin.org/

Disable page state in ASP.NET C# [duplicate]

This question already has answers here:
Webforms Refresh problem
(2 answers)
Closed 8 years ago.
I´ve an WebForms application with a simple form which persists values in the DB. The problem is: if I refresh this page (a simple F5), even when the form fields are empty, the last values are persisted again in the DB.
I just want to disable this behavior. How can I do this?
Thanks!
This can be solved with the post-redirect-get pattern. When submitting the form (POST request) the server redirects to a page (e.g. the detail page of the object just modified). This way you "clear" the POST request from the browser history. The user can easily navigate back without having anything saved again. Of course, if he hits the submit button again the form will be stored again.

First page with QueryString [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How to load index page with QueryString in asp.net? I know that we can redirect to a particular page with QueryString, but what I want is to load first page with some querystring.
If you are setting start action in Property pages of your application then you can follow following steps
1) right click on your project in solution explores
2) Go to Property pages
3) Set start action to 'Specific Page' and value = "index.aspx?a=22"
A very simple way to make it work on both local and remote enviroments is to, at page_load(), detect if the desired QueryString content is present.
If not, Use Response.Redirect pointing to the current page with the added QueryString parameters. Example follows:
if (Request.QueryString["QSEntry"] == null)
Response.Redirect("Page.aspx?QSEntry=desiredValue");
Pro: It'll work the way you want.
Con: You're actually loading the page twice (first time it's a parameterless load), so don't forget to take that into consideration.

Hide master page content in pages which are using it at design mode [duplicate]

This question already has answers here:
How to hide content on certain pages and not others via a Master Page?
(2 answers)
Closed 9 years ago.
My maser page is broken and thus when trying to design my pages which are inheriting master page is shown ugly and non-editable.
Is there a way to hide master page content in design mode so I can continue to editing my pages without trouble for dealing with master page content ?
There must be a way to disable it.. Maybe some extension ?
Try to hide the control using:
style="display:none"
in the style tag.
I don't think there is an option to hide the master page content in design view. Not even VS 2012 has that option.

Categories